diff options
author | Thomas Haller <thaller@redhat.com> | 2017-09-01 13:38:13 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-09-08 11:05:05 +0200 |
commit | 199499967a04b123f2a842a94bdb637c3ac74a76 (patch) | |
tree | 76ade1106d241d454ac708d1b7af377ef379139c | |
parent | 315bd0a97d0f05f0e04297a48ed62d92d1b3aa9b (diff) |
core: don't loop twice over routes in nm_ip4_config_capture()
and nm_ip6_config_capture().
-rw-r--r-- | src/nm-ip4-config.c | 12 | ||||
-rw-r--r-- | src/nm-ip6-config.c | 13 |
2 files changed, 8 insertions, 17 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index bd9f9beb2..0603a4348 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -679,14 +679,6 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i } priv->has_gateway = TRUE; } - } - - /* we detect the route metric based on the default route. All non-default - * routes have their route metrics explicitly set. */ - priv->route_metric = priv->has_gateway ? (gint64) lowest_metric : (gint64) -1; - - nmp_cache_iter_for_each (&iter, head_entry, &plobj) { - const NMPlatformIP4Route *route = NMP_OBJECT_CAST_IP4_ROUTE (plobj); if (route->rt_source == NM_IP_CONFIG_SOURCE_RTPROT_KERNEL) continue; @@ -695,6 +687,10 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i _add_route (self, plobj, NULL); } + /* we detect the route metric based on the default route. All non-default + * routes have their route metrics explicitly set. */ + priv->route_metric = priv->has_gateway ? (gint64) lowest_metric : (gint64) -1; + /* If the interface has the default route, and has IPv4 addresses, capture * nameservers from /etc/resolv.conf. */ diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index feee1f71c..5bc17cd18 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -471,23 +471,18 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i } has_gateway = TRUE; } - } - - /* we detect the route metric based on the default route. All non-default - * routes have their route metrics explicitly set. */ - priv->route_metric = has_gateway ? (gint64) lowest_metric : (gint64) -1; - - nmp_cache_iter_for_each (&iter, head_entry, &plobj) { - const NMPlatformIP6Route *route = NMP_OBJECT_CAST_IP6_ROUTE (plobj); if (route->rt_source == NM_IP_CONFIG_SOURCE_RTPROT_KERNEL) continue; if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) continue; - _add_route (self, plobj, NULL); } + /* we detect the route metric based on the default route. All non-default + * routes have their route metrics explicitly set. */ + priv->route_metric = has_gateway ? (gint64) lowest_metric : (gint64) -1; + /* If the interface has the default route, and has IPv6 addresses, capture * nameservers from /etc/resolv.conf. */ |