From fb83d623958b67c5335c18233eacee4cb577d164 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 3 Aug 2018 10:54:17 +0200 Subject: [PATCH 1/2] device: clear queued IP config sources when the device is unrealized If the device is later realized again, we assert that there aren't any IP config changes queued. Therefore, they must be cleared on unrealize(). (cherry picked from commit 9ed07fbb46c7dfbd4db8f1a908d4a522dc4917b4) --- src/devices/nm-device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 19e43762b9..52ed227179 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4236,6 +4236,9 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) } } + nm_clear_g_source (&priv->queued_ip_config_id_4); + nm_clear_g_source (&priv->queued_ip_config_id_6); + g_object_freeze_notify (G_OBJECT (self)); NM_DEVICE_GET_CLASS (self)->unrealize_notify (self); From 17a89f7061310c71506ccf5d62a4971c9ec28dc8 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 2 Aug 2018 17:45:09 +0200 Subject: [PATCH 2/2] manager: don't update ifindex of existing devices When NM has to rebuild the platform cache, it first generates ADD and then REMOVE events for the links. So, if an interface is removed and readded, platform will emit the ADDED event with a new ifindex while the device with old ifindex still exists. In such case the manager currently updates the device's ifindex but this causes problems as the DNS manager tracks configurations by their ifindex and so the configurations for the old device will become stale. Fix this by removing the device and adding it again when we detect a change of ifindex on a device that already had valid one. https://bugzilla.redhat.com/show_bug.cgi?id=1542366 (cherry picked from commit 281974b93216a33941b9527d823c9e20d9087bc4) --- src/nm-manager.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 289dcf8382..ad906169fa 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3008,10 +3008,21 @@ platform_link_added (NMManager *self, continue; if (nm_device_is_real (candidate)) { - /* Ignore the link added event since there's already a realized - * device with the link's name. + /* There's already a realized device with the link's name + * and a different ifindex. */ - nm_device_update_from_platform_link (candidate, plink); + if (nm_device_get_ifindex (candidate) <= 0) + nm_device_update_from_platform_link (candidate, plink); + else { + /* The ifindex of a device can't be changed after + * initialization because it is used as a key by + * the dns-manager. + */ + _LOGD (LOGD_DEVICE, "(%s): removing old device %p after ifindex change from %d to %d", + plink->name, candidate, nm_device_get_ifindex (candidate), ifindex); + remove_device (self, candidate, FALSE, TRUE); + goto add; + } return; } else if (nm_device_realize_start (candidate, plink, @@ -3031,6 +3042,7 @@ platform_link_added (NMManager *self, /* Try next unrealized device */ } +add: /* Try registered device factories */ factory = nm_device_factory_manager_find_factory_for_link_type (plink->type); if (factory) {