device: when setting back a device to managed, update internal sys state

Otherwise a device which was set as unmanaged (updated to the REMOVED
internal sys-state) will never update its own sys-state if later set
back as managed.
Manage either when setting explictly the device to managed either when
just upping a connection on an unmanaged device.
This commit is contained in:
Francesco Giudici 2017-05-19 17:34:23 +02:00
parent 55b8ba4ddc
commit adbf383628
2 changed files with 9 additions and 2 deletions

View file

@ -13858,9 +13858,14 @@ set_property (GObject *object, guint prop_id,
NMDeviceStateReason reason;
managed = g_value_get_boolean (value);
if (managed)
if (managed) {
reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED;
else {
if (NM_IN_SET_TYPED (NMDeviceSysIfaceState,
priv->sys_iface_state,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_REMOVED))
nm_device_sys_iface_state_set (self, NM_DEVICE_SYS_IFACE_STATE_ASSUME);
} else {
reason = NM_DEVICE_STATE_REASON_REMOVED;
nm_device_sys_iface_state_set (self, NM_DEVICE_SYS_IFACE_STATE_REMOVED);
}

View file

@ -3138,6 +3138,8 @@ unmanaged_to_disconnected (NMDevice *device)
* and force the device to be managed. */
nm_device_set_unmanaged_by_flags (device, NM_UNMANAGED_PLATFORM_INIT, FALSE, NM_DEVICE_STATE_REASON_USER_REQUESTED);
if (nm_device_sys_iface_state_get (device) == NM_DEVICE_SYS_IFACE_STATE_REMOVED)
nm_device_sys_iface_state_set (device, NM_DEVICE_SYS_IFACE_STATE_ASSUME);
nm_device_set_unmanaged_by_flags (device, NM_UNMANAGED_USER_EXPLICIT, FALSE, NM_DEVICE_STATE_REASON_USER_REQUESTED);
g_return_if_fail (nm_device_get_managed (device, FALSE));