device: remove the possibility of inheriting the unmanaged condition from the parent of a device

This commit is part of a broader change that eliminates inheriting
the unmanaged condition from the parent of a device, for all device
types:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1418

What motivates this change are the unncessary issues brought by this
inheritance. You can see some problems described here:
https://bugzilla.redhat.com/show_bug.cgi?id=2110307#c0.
This commit is contained in:
Ana Cabral 2022-10-12 19:26:27 +02:00
parent 412c7449b3
commit 0a280c5a93
3 changed files with 17 additions and 22 deletions

View file

@ -7667,9 +7667,9 @@ nm_device_unrealize(NMDevice *self, gboolean remove_resources, GError **error)
nm_device_set_unmanaged_flags(self, NM_UNMANAGED_PLATFORM_INIT, TRUE);
nm_device_set_unmanaged_flags(self,
NM_UNMANAGED_PARENT | NM_UNMANAGED_BY_TYPE
| NM_UNMANAGED_USER_UDEV | NM_UNMANAGED_USER_EXPLICIT
| NM_UNMANAGED_EXTERNAL_DOWN | NM_UNMANAGED_IS_SLAVE,
NM_UNMANAGED_BY_TYPE | NM_UNMANAGED_USER_UDEV
| NM_UNMANAGED_USER_EXPLICIT | NM_UNMANAGED_EXTERNAL_DOWN
| NM_UNMANAGED_IS_SLAVE,
NM_UNMAN_FLAG_OP_FORGET);
nm_device_state_changed(self,
@ -14142,7 +14142,6 @@ NM_UTILS_FLAGS2STR_DEFINE(nm_unmanaged_flags2str,
NMUnmanagedFlags,
NM_UTILS_FLAGS2STR(NM_UNMANAGED_SLEEPING, "sleeping"),
NM_UTILS_FLAGS2STR(NM_UNMANAGED_QUITTING, "quitting"),
NM_UTILS_FLAGS2STR(NM_UNMANAGED_PARENT, "parent"),
NM_UTILS_FLAGS2STR(NM_UNMANAGED_BY_TYPE, "by-type"),
NM_UTILS_FLAGS2STR(NM_UNMANAGED_PLATFORM_INIT, "platform-init"),
NM_UTILS_FLAGS2STR(NM_UNMANAGED_USER_EXPLICIT, "user-explicit"),

View file

@ -566,7 +566,6 @@ void nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device);
* @NM_UNMANAGED_NONE: placeholder value
* @NM_UNMANAGED_SLEEPING: %TRUE when unmanaged because NM is sleeping.
* @NM_UNMANAGED_QUITTING: %TRUE when unmanaged because NM is shutting down.
* @NM_UNMANAGED_PARENT: %TRUE when unmanaged due to parent device being unmanaged
* @NM_UNMANAGED_BY_TYPE: %TRUE for unmanaging device by type, like loopback.
* @NM_UNMANAGED_PLATFORM_INIT: %TRUE when unmanaged because platform link not
* yet initialized. Unrealized device are also unmanaged for this reason.
@ -597,21 +596,20 @@ typedef enum {
* the device cannot be managed. */
NM_UNMANAGED_SLEEPING = (1LL << 0),
NM_UNMANAGED_QUITTING = (1LL << 1),
NM_UNMANAGED_PARENT = (1LL << 2),
NM_UNMANAGED_BY_TYPE = (1LL << 3),
NM_UNMANAGED_PLATFORM_INIT = (1LL << 4),
NM_UNMANAGED_USER_EXPLICIT = (1LL << 5),
NM_UNMANAGED_USER_SETTINGS = (1LL << 6),
NM_UNMANAGED_BY_TYPE = (1LL << 2),
NM_UNMANAGED_PLATFORM_INIT = (1LL << 3),
NM_UNMANAGED_USER_EXPLICIT = (1LL << 4),
NM_UNMANAGED_USER_SETTINGS = (1LL << 5),
/* These flags can be non-effective and be overwritten
* by other flags. */
NM_UNMANAGED_BY_DEFAULT = (1LL << 7),
NM_UNMANAGED_USER_CONF = (1LL << 8),
NM_UNMANAGED_USER_UDEV = (1LL << 9),
NM_UNMANAGED_EXTERNAL_DOWN = (1LL << 10),
NM_UNMANAGED_IS_SLAVE = (1LL << 11),
NM_UNMANAGED_BY_DEFAULT = (1LL << 6),
NM_UNMANAGED_USER_CONF = (1LL << 7),
NM_UNMANAGED_USER_UDEV = (1LL << 8),
NM_UNMANAGED_EXTERNAL_DOWN = (1LL << 9),
NM_UNMANAGED_IS_SLAVE = (1LL << 10),
NM_UNMANAGED_ALL = ((1LL << 12) - 1),
NM_UNMANAGED_ALL = ((1LL << 11) - 1),
} NMUnmanagedFlags;
typedef enum {

View file

@ -3083,10 +3083,9 @@ 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 unmanaged by NM_UNMANAGED_PLATFORM_INIT or NM_UNMANAGED_PARENT,
/* If the device is 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_UNMANAGED_PARENT))
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 device is not managed");
return FALSE;
@ -3410,10 +3409,9 @@ _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 unmanaged by NM_UNMANAGED_PLATFORM_INIT or NM_UNMANAGED_PARENT,
/* If the device is 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_UNMANAGED_PARENT))
if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) & ~NM_UNMANAGED_PLATFORM_INIT)
nm_device_assume_state_reset(device);
return;
}