diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2021-05-11 14:44:20 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2021-05-12 15:14:53 +0200 |
commit | f69639925b509158c90dd37e3a368cc93b673198 (patch) | |
tree | 572dc21acab0ad784a2023f184cc3611d321eaad | |
parent | fea3fdecfacf0681c7b4e615c67a034a98b53ebd (diff) | |
download | NetworkManager-bg/assume-1-30.tar.gz |
core: don't reset assume state too earlybg/assume-1-30
If the device is still unmanaged by platform-init (which means that
udev didn't emit the event for the interface) when the device gets
realized, we currently clear the assume state. Later, when the device
becomes managed, NM is not able to properly assume the device using
the UUID.
This situation arises when NM already configured the device in initrd
and after switch root udev runs again.
Among all unamanaged flags, platform-init is the only one that can be
delayed externally. We should not clear the assume state if the device
has only platform-init in the unmanaged flags.
-rw-r--r-- | src/core/devices/nm-device.c | 2 | ||||
-rw-r--r-- | src/core/nm-manager.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 7c2a6d3250..163fb8a175 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -5414,11 +5414,11 @@ device_link_changed(NMDevice *self) /* Ensure the assume check is queued before any queued state changes * from the transition to UNAVAILABLE. */ - nm_device_queue_recheck_assume(self); reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; } } + nm_device_queue_recheck_assume(self); nm_device_set_unmanaged_by_flags(self, NM_UNMANAGED_PLATFORM_INIT, FALSE, reason); } diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 47d2cfc592..3dfe658054 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -2839,7 +2839,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)) { - nm_device_assume_state_reset(device); + /* If the device is only unmanaged by NM_UNMANAGED_PLATFORM_INIT, + * 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) + nm_device_assume_state_reset(device); _LOG2D(LOGD_DEVICE, device, "assume: don't assume because %s", "not managed"); return FALSE; } @@ -3160,7 +3163,10 @@ _device_realize_finish(NMManager *self, NMDevice *device, const NMPlatformLink * nm_device_realize_finish(device, plink); if (!nm_device_get_managed(device, FALSE)) { - nm_device_assume_state_reset(device); + /* If the device is only unmanaged by NM_UNMANAGED_PLATFORM_INIT, + * 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) + nm_device_assume_state_reset(device); return; } |