Commit 9e8218f9 authored by Thomas Haller's avatar Thomas Haller

device: leave device up when setting it as unmanaged by user

Before, setting a device to unmanaged causes it to go down and clear
the interface state.

It may be useful to instruct NetworkManager not to touch the device
anymore but leave the current state up. Changing behavior for

  nmcli device set "$DEV" managed no

To get the previous behavior, one has to first disconnect the interface
via

  nmcli device disconnect "$DEV"
  nmcli device set "$DEV" managed no

Note that non-permanent addresses like from DHCP will eventually time
out because NetworkManager stops the DHCP client. When instructing
NetworkManager to let go of the device, you have to take it over in
any way you see fit.

https://bugzilla.redhat.com/show_bug.cgi?id=1371433
parent a31ddcfc
......@@ -11984,7 +11984,7 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean
if (NM_DEVICE_GET_CLASS (self)->deactivate)
NM_DEVICE_GET_CLASS (self)->deactivate (self);
if (cleanup_type != CLEANUP_TYPE_KEEP) {
if (cleanup_type == CLEANUP_TYPE_DECONFIGURE) {
/* master: release slaves */
nm_device_master_release_slaves (self);
......@@ -12378,7 +12378,8 @@ _set_state_full (NMDevice *self,
/* Cache the activation request for the dispatcher */
req = nm_g_object_ref (priv->act_request);
if ( state > NM_DEVICE_STATE_UNMANAGED
if ( state > NM_DEVICE_STATE_UNMANAGED
&& state <= NM_DEVICE_STATE_ACTIVATED
&& nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_NOW_MANAGED
&& NM_IN_SET_TYPED (NMDeviceSysIfaceState,
priv->sys_iface_state,
......@@ -13845,8 +13846,10 @@ set_property (GObject *object, guint prop_id,
managed = g_value_get_boolean (value);
if (managed)
reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED;
else
else {
reason = NM_DEVICE_STATE_REASON_REMOVED;
nm_device_sys_iface_state_set (self, NM_DEVICE_SYS_IFACE_STATE_REMOVED);
}
nm_device_set_unmanaged_by_flags (self,
NM_UNMANAGED_USER_EXPLICIT,
!managed,
......
......@@ -34,6 +34,12 @@ typedef enum {
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME,
NM_DEVICE_SYS_IFACE_STATE_MANAGED,
/* the REMOVED state applies when the device is manually set to unmanaged
* or the link was externally removed. In both cases, we move the device
* to UNMANAGED state, without touching the link -- be it, because the link
* is already gone or because we want to release it (give it up).
*/
NM_DEVICE_SYS_IFACE_STATE_REMOVED,
} NMDeviceSysIfaceState;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment