summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-08-09 15:34:34 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-08-19 18:19:13 +0200
commit9364585eebdd2af9ccb1d5fbd5bd8e2e601963f6 (patch)
tree7a81d5cc099293a2dcdddf893894241cb23b6c8c
parenteff2dc63b4e5821a99f78904e4a9b062e71e077b (diff)
downloadNetworkManager-9364585eebdd2af9ccb1d5fbd5bd8e2e601963f6.tar.gz
device: don't flush addresses when unmanaging assumed devices
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 (cherry picked from commit 45cd3302dc2485bcf773c3e7144632a03a4d5d4e)
-rw-r--r--src/devices/nm-device.c29
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))