mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-11 09:18:38 +02:00
core: device: allow to change the admin state of the device in SetManaged()
Control it with a new NM_DEVICE_MANAGED_SET_ADMIN_STATE flag.
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.
(cherry picked from commit b9725dab73)
This commit is contained in:
parent
b3b9c4b0f6
commit
a35bca069c
2 changed files with 20 additions and 5 deletions
|
|
@ -14921,6 +14921,16 @@ set_managed(NMDevice *self, NMDeviceManaged managed, NMDeviceManagedFlags flags,
|
|||
NM_DEVICE_STATE_REASON_UNMANAGED_USER_EXPLICIT);
|
||||
} else {
|
||||
g_object_set(self, NM_DEVICE_MANAGED, !!managed, NULL);
|
||||
|
||||
/* 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) {
|
||||
if (nm_device_get_ifindex(self))
|
||||
nm_platform_link_change_flags(nm_device_get_platform(self),
|
||||
nm_device_get_ifindex(self),
|
||||
IFF_UP,
|
||||
!!managed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1271,6 +1271,10 @@ 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.
|
||||
* @NM_DEVICE_MANAGED_FLAGS_ALL: all flags.
|
||||
*
|
||||
* Flags for the SetManaged() D-Bus call of a device and nm_device_set_managed_async().
|
||||
|
|
@ -1278,12 +1282,13 @@ typedef enum {
|
|||
* Since: 1.58, 1.56.2
|
||||
*/
|
||||
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,
|
||||
|
||||
NM_DEVICE_MANAGED_FLAGS_ALL = 0x7, /* <skip> */
|
||||
NM_DEVICE_MANAGED_FLAGS_ALL = 0xF, /* <skip> */
|
||||
} NMDeviceManagedFlags;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue