diff options
author | Thomas Haller <thaller@redhat.com> | 2017-10-03 11:45:56 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-10-09 22:06:25 +0200 |
commit | 2bdfc092d40daaf1af87a4cc2285caa63f35e9d3 (patch) | |
tree | 2ee362b0b8c37e1d23ec7055069402665e0671a3 /src/nm-ip4-config.c | |
parent | 9003dae6cdc12fc4860d35b91d5799b1bf8d5638 (diff) |
core: don't track route metric in ip-config
It's not needed. Whenever we add a route, we pass in the
route metric (for example, based on the device's configuration).
No need to merge and track it into the NMIP4Config/NMIP6Config.
The metric was only used in nm_ip4_config_create_setting()
and nm_ip6_config_create_setting(). In fact it's wrong to do
that, because it means we first capture some settings, and guess
the configured route metric. But we cannot do that. Our best
guess what a configured setting might be is -1.
Diffstat (limited to 'src/nm-ip4-config.c')
-rw-r--r-- | src/nm-ip4-config.c | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 101b3b0fbc..b80ff8cc11 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -295,7 +295,6 @@ typedef struct { int ifindex; NMIPConfigSource mtu_source; gint dns_priority; - gint64 route_metric; GArray *nameservers; GPtrArray *domains; GPtrArray *searches; @@ -643,10 +642,6 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i _add_route (self, plobj, NULL, 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. */ @@ -880,9 +875,6 @@ nm_ip4_config_merge_setting (NMIP4Config *self, nm_ip4_config_set_gateway (self, gateway); } - if (priv->route_metric == -1) - priv->route_metric = nm_setting_ip_config_get_route_metric (setting); - /* Addresses */ for (i = 0; i < naddresses; i++) { NMIPAddress *s_addr = nm_setting_ip_config_get_address (setting, i); @@ -974,7 +966,6 @@ nm_ip4_config_create_setting (const NMIP4Config *self) guint nnameservers, nsearches, noptions; const char *method = NULL; int i; - gint64 route_metric; NMDedupMultiIter ipconf_iter; const NMPlatformIP4Address *address; const NMPlatformIP4Route *route; @@ -992,7 +983,6 @@ nm_ip4_config_create_setting (const NMIP4Config *self) nnameservers = nm_ip4_config_get_num_nameservers (self); nsearches = nm_ip4_config_get_num_searches (self); noptions = nm_ip4_config_get_num_dns_options (self); - route_metric = nm_ip4_config_get_route_metric (self); /* Addresses */ nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, self, &address) { @@ -1030,7 +1020,6 @@ nm_ip4_config_create_setting (const NMIP4Config *self) g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) route_metric, NULL); /* Routes */ @@ -1117,11 +1106,6 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl _add_route (dst, ipconf_iter.current->obj, NULL, NULL); } - if (dst_priv->route_metric == -1) - dst_priv->route_metric = src_priv->route_metric; - else if (src_priv->route_metric != -1) - dst_priv->route_metric = MIN (dst_priv->route_metric, src_priv->route_metric); - /* domains */ if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { for (i = 0; i < nm_ip4_config_get_num_domains (src); i++) @@ -1320,8 +1304,6 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src) if (!nm_ip4_config_get_num_addresses (dst)) nm_ip4_config_unset_gateway (dst); - /* ignore route_metric */ - /* routes */ changed = FALSE; changed_default_route = FALSE; @@ -1431,7 +1413,6 @@ nm_ip4_config_intersect (NMIP4Config *dst, const NMIP4Config *src) if (changed) _notify_addresses (dst); - /* ignore route_metric */ /* ignore nameservers */ /* default gateway */ @@ -1537,11 +1518,6 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev has_relevant_changes = TRUE; } - if (src_priv->route_metric != dst_priv->route_metric) { - dst_priv->route_metric = src_priv->route_metric; - has_minor_changes = TRUE; - } - /* addresses */ head_entry_src = nm_ip4_config_lookup_addresses (src); nm_dedup_multi_iter_init (&ipconf_iter_src, head_entry_src); @@ -1960,14 +1936,6 @@ nm_ip4_config_get_gateway (const NMIP4Config *self) return priv->gateway; } -gint64 -nm_ip4_config_get_route_metric (const NMIP4Config *self) -{ - const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self); - - return priv->route_metric; -} - /*****************************************************************************/ void @@ -3092,7 +3060,6 @@ nm_ip4_config_init (NMIP4Config *self) priv->dns_options = g_ptr_array_new_with_free_func (g_free); priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32)); priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32)); - priv->route_metric = -1; } NMIP4Config * |