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 3c4450aa4d ('core: don't reset assume state too
early') did something similar for NM_UNMANAGED_PLATFORM_INIT flag only.

(cherry picked from commit 87674740d8)
(cherry picked from commit 1b00c50d52)
This commit is contained in:
Wen Liang 2021-12-14 11:36:18 -05:00
parent 517e12c706
commit fc26b52281

View file

@ -2854,9 +2854,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;
@ -3179,9 +3180,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;
}