From 0d23ffdb6bb2cd3b1e68b8744a737050d443b234 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 30 Aug 2016 14:58:52 +0200 Subject: [PATCH] device: forget unmanaged-flag "user-explicit" for unrealized devices When a software device unrealizes, we want to forget about the "user-explict" unmanaged state. It means, that after a software device is deleted, the "user-explict" managed flag will be cleared for that device. It might be nice to preserve the managed-state after deletion of the device. However, the unrealized-device only exists as long as we have a connection for the device. That means, before this patch whether the unmanaged flag was forgotten depends on whether the user had some connections that keep the device alive as unrealized. That behavior was complicated, just don't do that. (cherry picked from commit 34880d62d0ad499465abff53389d56ea13e3921c) --- src/devices/nm-device.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6939332068..1523018740 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2526,6 +2526,7 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) NM_UNMANAGED_PARENT | NM_UNMANAGED_LOOPBACK | NM_UNMANAGED_USER_UDEV | + NM_UNMANAGED_USER_EXPLICIT | NM_UNMANAGED_EXTERNAL_DOWN | NM_UNMANAGED_IS_SLAVE, NM_UNMAN_FLAG_OP_FORGET); @@ -12350,21 +12351,22 @@ set_property (GObject *object, guint prop_id, case PROP_IP4_ADDRESS: priv->ip4_address = g_value_get_uint (value); break; - case PROP_MANAGED: { - gboolean managed; - NMDeviceStateReason reason; + case PROP_MANAGED: + if (nm_device_is_real (self)) { + gboolean managed; + NMDeviceStateReason reason; - managed = g_value_get_boolean (value); - if (managed) - reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; - else - reason = NM_DEVICE_STATE_REASON_REMOVED; - nm_device_set_unmanaged_by_flags (self, - NM_UNMANAGED_USER_EXPLICIT, - !managed, - reason); + managed = g_value_get_boolean (value); + if (managed) + reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; + else + reason = NM_DEVICE_STATE_REASON_REMOVED; + nm_device_set_unmanaged_by_flags (self, + NM_UNMANAGED_USER_EXPLICIT, + !managed, + reason); + } break; - } case PROP_AUTOCONNECT: nm_device_set_autoconnect (self, g_value_get_boolean (value)); break;