summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-04-18 14:46:27 +0200
committerThomas Haller <thaller@redhat.com>2017-04-18 15:52:44 +0200
commit9e8218f99a2d5a7020703e0fbac1c7c0983930db (patch)
treead2ea848755beb672bd11c64306557fbe92df002
parenta31ddcfca5abf13d5a6522615d2411692167eadf (diff)
downloadNetworkManager-th/device-release-rh1371433.tar.gz
device: leave device up when setting it as unmanaged by userth/device-release-rh1371433
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
-rw-r--r--src/devices/nm-device.c9
-rw-r--r--src/devices/nm-device.h6
2 files changed, 12 insertions, 3 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 29ff3741cf..9aeef9a87a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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,
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index f70a3e3ef5..be328eb6bf 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -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;