mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 14:00:15 +01: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
This commit is contained in:
parent
3fbbbb62f0
commit
cf9ba271e6
2 changed files with 17 additions and 1 deletions
|
|
@ -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++);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue