diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-17 10:24:41 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2023-07-12 15:30:05 +0200 |
commit | efa63aef3aeb063becea9161d4d25184dc896020 (patch) | |
tree | 2a7ee6cb483ca69663cd490b4406505295400935 | |
parent | 9a5c7c7228ce7ef389918113c89dec27ec9c84cb (diff) |
device: delete software device when software devices lose carrierbg/rh2156684-ignore-carrier-2
We delete devices when the connection goes down and NetworkManager
created the device earlier.
Software devices like bond/bridge/team default to ignoring carrier.
However, when configuring them to not ignore carrier
([device].ignore-carrier), they were not deleted when deactivating the
devices.
This adjusts commit d0c2a24b7140 ('device: do not remove software devices
on initial disconnected (rh #1035814)'). Note that back then there was
no check whether the device has an activation queued, so it behaved
differently then.
When the software device enters the UNAVAILABLE state from UNMANAGED,
during cleanup we shouldn't delete the link.
Co-Authored-By: Beniamino Galvani <bgalvani@redhat.com>
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1686
-rw-r--r-- | src/core/devices/nm-device.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index e2a49de53e..40b88db1b9 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -12899,11 +12899,9 @@ delete_on_deactivate_check_and_schedule(NMDevice *self) return; if (nm_device_get_state(self) == NM_DEVICE_STATE_UNMANAGED) return; - if (nm_device_get_state(self) == NM_DEVICE_STATE_UNAVAILABLE) - return; - delete_on_deactivate_unschedule(self); /* always cancel and reschedule */ g_object_ref(self); + delete_on_deactivate_unschedule(self); /* always cancel and reschedule */ priv->delete_on_deactivate_idle_source = nm_g_idle_add_source(delete_on_deactivate_link_delete, self); @@ -15748,7 +15746,7 @@ _cleanup_generic_pre(NMDevice *self, CleanupType cleanup_type) } static void -_cleanup_generic_post(NMDevice *self, CleanupType cleanup_type) +_cleanup_generic_post(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanup_type) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -15771,7 +15769,7 @@ _cleanup_generic_post(NMDevice *self, CleanupType cleanup_type) act_request_set(self, NULL); } - if (cleanup_type == CLEANUP_TYPE_DECONFIGURE) { + if (cleanup_type == CLEANUP_TYPE_DECONFIGURE && reason != NM_DEVICE_STATE_REASON_NOW_MANAGED) { /* Check if the device was deactivated, and if so, delete_link. * Don't call delete_link synchronously because we are currently * handling a state change -- which is not reentrant. */ @@ -15920,7 +15918,7 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu priv->promisc_reset = NM_OPTION_BOOL_DEFAULT; } - _cleanup_generic_post(self, cleanup_type); + _cleanup_generic_post(self, reason, cleanup_type); } static void @@ -18158,7 +18156,7 @@ dispose(GObject *object) /* Let the kernel manage IPv6LL again */ _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_EUI64); - _cleanup_generic_post(self, CLEANUP_TYPE_KEEP); + _cleanup_generic_post(self, NM_DEVICE_STATE_REASON_NONE, CLEANUP_TYPE_KEEP); nm_assert(priv->master_ready_id == 0); |