mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 13:38:43 +02:00
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
(cherry picked from commit cf9ba271e6)
This commit is contained in:
parent
a42f3b92b7
commit
333ed6ee2a
2 changed files with 17 additions and 1 deletions
|
|
@ -3011,6 +3011,19 @@ realize_start_setup (NMDevice *self,
|
||||||
|
|
||||||
_add_capabilities (self, capabilities);
|
_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) {
|
if (!priv->udi) {
|
||||||
/* Use a placeholder UDI until we get a real one */
|
/* Use a placeholder UDI until we get a real one */
|
||||||
priv->udi = g_strdup_printf ("/virtual/device/placeholder/%d", id++);
|
priv->udi = g_strdup_printf ("/virtual/device/placeholder/%d", id++);
|
||||||
|
|
|
||||||
|
|
@ -5008,6 +5008,7 @@ nm_manager_write_device_state (NMManager *self)
|
||||||
const GSList *devices;
|
const GSList *devices;
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
||||||
|
gint nm_owned;
|
||||||
|
|
||||||
seen_ifindexes = g_hash_table_new (NULL, NULL);
|
seen_ifindexes = g_hash_table_new (NULL, NULL);
|
||||||
|
|
||||||
|
|
@ -5047,11 +5048,13 @@ nm_manager_write_device_state (NMManager *self)
|
||||||
if (perm_hw_addr_fake && !perm_hw_addr_is_fake)
|
if (perm_hw_addr_fake && !perm_hw_addr_is_fake)
|
||||||
perm_hw_addr_fake = NULL;
|
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,
|
if (nm_config_device_state_write (ifindex,
|
||||||
managed_type,
|
managed_type,
|
||||||
perm_hw_addr_fake,
|
perm_hw_addr_fake,
|
||||||
uuid,
|
uuid,
|
||||||
-1))
|
nm_owned))
|
||||||
g_hash_table_add (seen_ifindexes, GINT_TO_POINTER (ifindex));
|
g_hash_table_add (seen_ifindexes, GINT_TO_POINTER (ifindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue