summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-08-30 14:58:52 +0200
committerThomas Haller <thaller@redhat.com>2016-08-30 18:06:07 +0200
commit34880d62d0ad499465abff53389d56ea13e3921c (patch)
treededcf2faf837de2ae5e92102633a2995da890cc0
parent145d199589d34f8844d8e9cafc3c2c2ea8ec4d53 (diff)
downloadNetworkManager-34880d62d0ad499465abff53389d56ea13e3921c.tar.gz
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.
-rw-r--r--src/devices/nm-device.c28
1 files 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;