From 9d18510437d47fe492aa455485aa8e86e7e23dfe Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 27 May 2023 15:46:08 +0200 Subject: manager: set the right reason when managing device after realize When managing a device after it is realized, we previously always set the NOW_MANAGED reason, that makes the device fully-managed. This works based on the assumption that initially an external device has unmanaged flag EXTERNAL_DOWN set, and therefore the device stays unmanaged during realization. It is possible that an external device appears already with addresses (or attached to a controller); we need to set reason CONNECTION_ASSUMED if it's an external device, so that we don't set sys-iface-state=managed. Reproducer: ip link add br1 type bridge killall -STOP NetworkManager ip link add dummy1 type dummy ip link set dummy1 master br1 ip link set dummy1 up sleep .5 killall -CONT NetworkManager After this, dummy1 is fully managed by NM while it shouldn't. https://bugzilla.redhat.com/show_bug.cgi?id=2149012 --- src/core/nm-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 239fd7070c..323d7476e3 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -3947,7 +3947,7 @@ _device_realize_finish(NMManager *self, NMDevice *device, const NMPlatformLink * * is still unavailable. Set UNAVAILABLE state again, this time with NOW_MANAGED. */ nm_device_state_changed(device, NM_DEVICE_STATE_UNAVAILABLE, - NM_DEVICE_STATE_REASON_NOW_MANAGED); + nm_device_get_manage_reason_external(device)); nm_manager_device_recheck_auto_activate_schedule(self, device); } -- cgit v1.2.3