diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-05-31 16:58:21 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-06-07 10:27:02 +0200 |
commit | cf9ba271e664ffd93f6ba6294ebc5f7e341a9a78 (patch) | |
tree | b145962fa6aba5a95e86914528ae77940904971c | |
parent | 3fbbbb62f0b18a1efdc25ee0c01625ae8da65826 (diff) | |
download | NetworkManager-cf9ba271e664ffd93f6ba6294ebc5f7e341a9a78.tar.gz |
manager: restore the previous persistent nm-owned state of devices
After a daemon restart, any software device is considered !nm-owned,
even if it was created by NM. Therefore, a device stays around even if
the connection which created it gets deactivated or deleted.
Fix this by remembering the previous nm-owned state in the device
state file.
https://bugzilla.redhat.com/show_bug.cgi?id=1376199
-rw-r--r-- | src/devices/nm-device.c | 13 | ||||
-rw-r--r-- | src/nm-manager.c | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 9f9605166d..ee0c64affa 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3012,6 +3012,19 @@ realize_start_setup (NMDevice *self, _add_capabilities (self, capabilities); + /* Update nm-owned flag according to state file */ + if ( !priv->nm_owned + && priv->ifindex > 0 + && nm_device_is_software (self)) { + gs_free NMConfigDeviceStateData *dev_state = NULL; + + dev_state = nm_config_device_state_load (priv->ifindex); + if (dev_state && dev_state->nm_owned == TRUE) { + priv->nm_owned = TRUE; + _LOGD (LOGD_DEVICE, "set nm-owned from state file"); + } + } + if (!priv->udi) { /* Use a placeholder UDI until we get a real one */ priv->udi = g_strdup_printf ("/virtual/device/placeholder/%d", id++); diff --git a/src/nm-manager.c b/src/nm-manager.c index 16303c0bae..8d1bf320f3 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4987,6 +4987,7 @@ nm_manager_write_device_state (NMManager *self) const GSList *devices; NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); gs_unref_hashtable GHashTable *seen_ifindexes = NULL; + gint nm_owned; seen_ifindexes = g_hash_table_new (NULL, NULL); @@ -5026,11 +5027,13 @@ nm_manager_write_device_state (NMManager *self) if (perm_hw_addr_fake && !perm_hw_addr_is_fake) perm_hw_addr_fake = NULL; + nm_owned = nm_device_is_software (device) ? nm_device_is_nm_owned (device) : -1; + if (nm_config_device_state_write (ifindex, managed_type, perm_hw_addr_fake, uuid, - -1)) + nm_owned)) g_hash_table_add (seen_ifindexes, GINT_TO_POINTER (ifindex)); } |