From 4fc6f5f3177903a23deda1384d9bb88fc5c933f4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 24 Sep 2018 16:35:25 +0200 Subject: [PATCH] device: don't remove routes when the interface is down In update update_ext_ip_config() we remove from various internal configurations those addresses and routes that were removed externally by users. When the interface is brought down, the kernel automatically removes routes associated with it and so we should not consider them as "removed by users". Instead, keep them so that they can be restored when the interface comes up again. (cherry picked from commit f069c98cc95494891215ddf261661afb742744ba) (cherry picked from commit ce2d403530451a60357dcd1ce815977079f539f6) --- src/devices/nm-device.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 1f4a6fdbf5..134753eb6f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -12159,6 +12159,7 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_config NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); int ifindex; GSList *iter; + gboolean is_up; nm_assert_addr_family (addr_family); @@ -12166,6 +12167,8 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_config if (!ifindex) return FALSE; + is_up = nm_platform_link_is_up (nm_device_get_platform (self), ifindex); + if (addr_family == AF_INET) { g_clear_object (&priv->ext_ip_config_4); @@ -12180,15 +12183,15 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_config * by the user. */ if (priv->con_ip_config_4) { nm_ip4_config_intersect (priv->con_ip_config_4, priv->ext_ip_config_4, - TRUE, + is_up, default_route_metric_penalty_get (self, AF_INET)); } - intersect_ext_config (self, &priv->dev_ip4_config, TRUE); - intersect_ext_config (self, &priv->wwan_ip_config_4, TRUE); + intersect_ext_config (self, &priv->dev_ip4_config, is_up); + intersect_ext_config (self, &priv->wwan_ip_config_4, is_up); for (iter = priv->vpn_configs_4; iter; iter = iter->next) - nm_ip4_config_intersect (iter->data, priv->ext_ip_config_4, TRUE, 0); + nm_ip4_config_intersect (iter->data, priv->ext_ip_config_4, is_up, 0); } /* Remove parts from ext_ip_config_4 to only contain the information that @@ -12232,16 +12235,16 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_config * by the user. */ if (priv->con_ip_config_6) { nm_ip6_config_intersect (priv->con_ip_config_6, priv->ext_ip_config_6, - TRUE, + is_up, default_route_metric_penalty_get (self, AF_INET6)); } - intersect_ext_config (self, &priv->ac_ip6_config, TRUE); - intersect_ext_config (self, &priv->dhcp6.ip6_config, TRUE); - intersect_ext_config (self, &priv->wwan_ip_config_6, TRUE); + intersect_ext_config (self, &priv->ac_ip6_config, is_up); + intersect_ext_config (self, &priv->dhcp6.ip6_config, is_up); + intersect_ext_config (self, &priv->wwan_ip_config_6, is_up); for (iter = priv->vpn_configs_6; iter; iter = iter->next) - nm_ip6_config_intersect (iter->data, priv->ext_ip_config_6, TRUE, 0); + nm_ip6_config_intersect (iter->data, priv->ext_ip_config_6, is_up, 0); if ( priv->ipv6ll_has && !nm_ip6_config_lookup_address (priv->ext_ip_config_6, &priv->ipv6ll_addr))