diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index cffcd998d6..c43663cb37 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -15010,6 +15010,15 @@ set_managed(NMDevice *self, NMDeviceManaged managed, NMDeviceManagedFlags flags, g_object_get(self, NM_DEVICE_MANAGED, &managed_new, NULL); if (managed_old != managed_new) _notify(self, PROP_MANAGED); + + /* If requested, set the administrative state of the device to UP if the + * new managed state is YES, and to DOWN if it's NO. */ + 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); + } } } diff --git a/src/libnm-core-public/nm-dbus-interface.h b/src/libnm-core-public/nm-dbus-interface.h index 22a730a29f..08405b7639 100644 --- a/src/libnm-core-public/nm-dbus-interface.h +++ b/src/libnm-core-public/nm-dbus-interface.h @@ -1268,16 +1268,21 @@ typedef enum { * @NM_DEVICE_MANAGED_FLAGS_PERMANENT: to set the device managed state to the permanent (on disk) value. * @NM_DEVICE_MANAGED_FLAGS_BY_MAC: to match the device by MAC address, not by name. * This option only makes sense together with %NM_DEVICE_MANAGED_FLAGS_PERMANENT. + * @NM_DEVICE_MANAGED_FLAGS_SET_ADMIN_STATE: to set the administrative state of the + * device to up if the managed state is %NM_DEVICE_MANAGED_YES, and down if the managed state + * is %NM_DEVICE_MANAGED_NO. If the flag is not set, the administrative state is not changed. + * The flag is ignored for %NM_DEVICE_MANAGED_RESET. * * Flags for the SetManaged() D-Bus call of a device and nm_device_set_managed_async(). * * Since: 1.58 */ typedef enum /*< flags >*/ { - NM_DEVICE_MANAGED_FLAGS_NONE = 0, - NM_DEVICE_MANAGED_FLAGS_RUNTIME = 0x1, - NM_DEVICE_MANAGED_FLAGS_PERMANENT = 0x2, - NM_DEVICE_MANAGED_FLAGS_BY_MAC = 0x4, + NM_DEVICE_MANAGED_FLAGS_NONE = 0, + NM_DEVICE_MANAGED_FLAGS_RUNTIME = 0x1, + NM_DEVICE_MANAGED_FLAGS_PERMANENT = 0x2, + NM_DEVICE_MANAGED_FLAGS_BY_MAC = 0x4, + NM_DEVICE_MANAGED_FLAGS_SET_ADMIN_STATE = 0x8, } NMDeviceManagedFlags; /**