mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 08:40:09 +01:00
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 45cd3302dc)
This commit is contained in:
parent
eff2dc63b4
commit
9364585eeb
1 changed files with 16 additions and 13 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue