summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-29 19:39:06 +0200
committerThomas Haller <thaller@redhat.com>2014-07-29 23:42:50 +0200
commite273ff4fe782df6a8e78c74315bb7c172a8fb545 (patch)
tree4e7da26abeb155b2aad4487a364fb24498ce57df
parent06703c1670d0f96834b268920b09792e22fdb4c4 (diff)
core: refactor nm_ip[46]_config_commit() not to make a copy of route
In nm_ip4_config_commit() and nm_ip6_config_commit() there is no need to copy the route. Just use the pointer returned from nm_ip4_config_get_route()/ nm_ip6_config_get_route(). Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/nm-ip4-config.c12
-rw-r--r--src/nm-ip6-config.c12
2 files changed, 12 insertions, 12 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index 62a6b19218..b286edb995 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -259,27 +259,27 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex)
{
int count = nm_ip4_config_get_num_routes (config);
GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Route), count);
- NMPlatformIP4Route route;
+ const NMPlatformIP4Route *route;
gboolean success;
for (i = 0; i < count; i++) {
- memcpy (&route, nm_ip4_config_get_route (config, i), sizeof (route));
+ route = nm_ip4_config_get_route (config, i);
/* Don't add the route if it's more specific than one of the subnets
* the device already has an IP address on.
*/
- if ( route.gateway == 0
- && nm_ip4_config_destination_is_direct (config, route.network, route.plen))
+ if ( route->gateway == 0
+ && nm_ip4_config_destination_is_direct (config, route->network, route->plen))
continue;
/* Don't add the default route if the connection
* is never supposed to be the default connection.
*/
if ( nm_ip4_config_get_never_default (config)
- && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&route))
+ && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route))
continue;
- g_array_append_val (routes, route);
+ g_array_append_vals (routes, route, 1);
}
success = nm_platform_ip4_route_sync (ifindex, routes);
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index 5012c57515..0d4307f288 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -371,26 +371,26 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
{
int count = nm_ip6_config_get_num_routes (config);
GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP6Route), count);
- NMPlatformIP6Route route;
+ const NMPlatformIP6Route *route;
for (i = 0; i < count; i++) {
- memcpy (&route, nm_ip6_config_get_route (config, i), sizeof (route));
+ route = nm_ip6_config_get_route (config, i);
/* Don't add the route if it's more specific than one of the subnets
* the device already has an IP address on.
*/
- if ( IN6_IS_ADDR_UNSPECIFIED (&route.gateway)
- && nm_ip6_config_destination_is_direct (config, &route.network, route.plen))
+ if ( IN6_IS_ADDR_UNSPECIFIED (&route->gateway)
+ && nm_ip6_config_destination_is_direct (config, &route->network, route->plen))
continue;
/* Don't add the default route if the connection
* is never supposed to be the default connection.
*/
if ( nm_ip6_config_get_never_default (config)
- && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&route))
+ && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route))
continue;
- g_array_append_val (routes, route);
+ g_array_append_vals (routes, route, 1);
}
success = nm_platform_ip6_route_sync (ifindex, routes);