diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-08-09 15:34:34 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-08-18 11:07:56 +0200 |
commit | 8b590e763cbf787ebcf5fdd4d4bc4876b921f498 (patch) | |
tree | c6508fde14cd66fb5fc05f754fe2ddaa4ce6c653 | |
parent | ac5dc1a9510c086c54c365b1160a51cc25402010 (diff) | |
download | NetworkManager-8b590e763cbf787ebcf5fdd4d4bc4876b921f498.tar.gz |
device: don't flush addresses when unmanaging assumed devicesbg/rh1363995
When a assumed software device is brought down externally, it becomes
UNMANAGED_EXTERNAL_DOWN and its state goes from ACTIVATED directly to
UNMANAGED. In such case, we shouldn't flush the IP configuration
(addresses and routes) present on the device.
To fix this, clean up the device with CLEANUP_TYPE_KEEP and modify
nm_device_cleanup() not to flush addresses and devices with such flag.
https://bugzilla.redhat.com/show_bug.cgi?id=1363995
-rw-r--r-- | src/devices/nm-device.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 7e41e9e743..44e22ff9c0 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -163,9 +163,9 @@ typedef struct { } ActivationHandleData; typedef enum { - CLEANUP_TYPE_DECONFIGURE, CLEANUP_TYPE_KEEP, CLEANUP_TYPE_REMOVED, + CLEANUP_TYPE_DECONFIGURE, } CleanupType; typedef enum { @@ -10790,19 +10790,21 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean if (NM_DEVICE_GET_CLASS (self)->deactivate) NM_DEVICE_GET_CLASS (self)->deactivate (self); - /* master: release slaves */ - nm_device_master_release_slaves (self); + if (cleanup_type != CLEANUP_TYPE_KEEP) { + /* master: release slaves */ + nm_device_master_release_slaves (self); - /* slave: mark no longer enslaved */ - if ( priv->master - && nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) <= 0) - nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); + /* slave: mark no longer enslaved */ + if ( priv->master + && nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) <= 0) + nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); - /* Take out any entries in the routing table and any IP address the device had. */ - ifindex = nm_device_get_ip_ifindex (self); - if (ifindex > 0) { - nm_route_manager_route_flush (nm_route_manager_get (), ifindex); - nm_platform_address_flush (NM_PLATFORM_GET, ifindex); + /* Take out any entries in the routing table and any IP address the device had. */ + ifindex = nm_device_get_ip_ifindex (self); + if (ifindex > 0) { + nm_route_manager_route_flush (nm_route_manager_get (), ifindex); + nm_platform_address_flush (NM_PLATFORM_GET, ifindex); + } } if (priv->lldp_listener) @@ -10810,7 +10812,6 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean nm_device_update_metered (self); - /* during device cleanup, we want to reset the MAC address of the device * to the initial state. * @@ -11180,6 +11181,8 @@ _set_state_full (NMDevice *self, if (old_state > NM_DEVICE_STATE_UNMANAGED) { if (reason == NM_DEVICE_STATE_REASON_REMOVED) { nm_device_cleanup (self, reason, CLEANUP_TYPE_REMOVED); + } else if (reason == NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED) { + nm_device_cleanup (self, reason, CLEANUP_TYPE_KEEP); } else { /* Clean up if the device is now unmanaged but was activated */ if (nm_device_get_act_request (self)) |