From 2fb76ed1266927b30a45260e1cebe81860625b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Fri, 13 Feb 2026 15:41:27 +0100 Subject: [PATCH] dbus: add a SET_ADMIN_STATE flag to SetManaged() This flag will make that, at the same time that the device is moved to managed/unmanaged, it's admin state is set to up/down. Many users want to have a way to have their devices in a DOWN admin state when they are not using them. Because of the complex activation process, NM wants to have its devices in UP state all the time. However, it is not a problem to have it DOWN if we are not managing it. --- src/core/devices/nm-device.c | 7 +++++++ src/libnm-core-public/nm-dbus-interface.h | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index c3cff1a77b..1b6e2faf10 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -15010,6 +15010,13 @@ set_managed(NMDevice *self, gboolean managed, NMDeviceManagedFlags flags, GError if (managed_old != managed) _notify(self, PROP_MANAGED); + if (flags & NM_DEVICE_MANAGED_FLAGS_SET_ADMIN_STATE) { + nm_platform_link_change_flags(nm_device_get_platform(self), + nm_device_get_ifindex(self), + IFF_UP, + managed); + } + return TRUE; } diff --git a/src/libnm-core-public/nm-dbus-interface.h b/src/libnm-core-public/nm-dbus-interface.h index f5842c5fc7..ac6a5411ce 100644 --- a/src/libnm-core-public/nm-dbus-interface.h +++ b/src/libnm-core-public/nm-dbus-interface.h @@ -1265,10 +1265,11 @@ typedef enum /*< flags >*/ { * Since: 1.58 */ typedef enum /*< flags >*/ { - NM_DEVICE_MANAGED_FLAGS_NONE = 0, - NM_DEVICE_MANAGED_FLAGS_TO_DISK = 0x1, - NM_DEVICE_MANAGED_FLAGS_BY_MAC = 0x2, - NM_DEVICE_MANAGED_FLAGS_CLEAR_DISK = 0x4, + NM_DEVICE_MANAGED_FLAGS_NONE = 0, + NM_DEVICE_MANAGED_FLAGS_TO_DISK = 0x1, + NM_DEVICE_MANAGED_FLAGS_BY_MAC = 0x2, + NM_DEVICE_MANAGED_FLAGS_CLEAR_DISK = 0x4, + NM_DEVICE_MANAGED_FLAGS_SET_ADMIN_STATE = 0x8, } NMDeviceManagedFlags; /**