From 87674740d87b42b381b836f4dc6c0598d4746d49 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Tue, 14 Dec 2021 11:36:18 -0500 Subject: [PATCH] core: don't reset assume state if the device is unmanaged by parent When the device gets realized, similar to the situation that the device is unmanaged by platform-init, if the device is still unmanaged by parent and we clear the assume state. Then, when the device becomes managed, NM is not able to properly assume the device using the UUID. Therefore, we should not clear the assume state if the device has only the NM_UNMANAGED_PLATFORM_INIT or the NM_UNMANAGED_PARENT flag set in the unmanaged flags. The previous commit 3c4450aa4da1 ('core: don't reset assume state too early') did something similar for NM_UNMANAGED_PLATFORM_INIT flag only. --- src/core/nm-manager.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 0066b8d45b..d94bdbb986 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -2848,9 +2848,10 @@ recheck_assume_connection(NMManager *self, NMDevice *device) g_return_val_if_fail(NM_IS_DEVICE(device), FALSE); if (!nm_device_get_managed(device, FALSE)) { - /* If the device is only unmanaged by NM_UNMANAGED_PLATFORM_INIT, + /* If the device is unmanaged by NM_UNMANAGED_PLATFORM_INIT or NM_UNMANAGED_PARENT, * don't reset the state now but wait until it becomes managed. */ - if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) != NM_UNMANAGED_PLATFORM_INIT) + if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) + & ~(NM_UNMANAGED_PLATFORM_INIT | NM_UNMANAGED_PARENT)) nm_device_assume_state_reset(device); _LOG2D(LOGD_DEVICE, device, "assume: don't assume because %s", "not managed"); return FALSE; @@ -3173,9 +3174,10 @@ _device_realize_finish(NMManager *self, NMDevice *device, const NMPlatformLink * nm_device_realize_finish(device, plink); if (!nm_device_get_managed(device, FALSE)) { - /* If the device is only unmanaged by NM_UNMANAGED_PLATFORM_INIT, + /* If the device is unmanaged by NM_UNMANAGED_PLATFORM_INIT or NM_UNMANAGED_PARENT, * don't reset the state now but wait until it becomes managed. */ - if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) != NM_UNMANAGED_PLATFORM_INIT) + if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) + & ~(NM_UNMANAGED_PLATFORM_INIT | NM_UNMANAGED_PARENT)) nm_device_assume_state_reset(device); return; }