From 94ef9017780e92a18367b7427eb70dd865300cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Fri, 13 Feb 2026 16:07:09 +0100 Subject: [PATCH] nmcli: add managed states up and down Up means managed=yes and set device's administrative state UP. Down means managed=no and admin state DOWN. --- man/nmcli.xml | 8 ++++++++ src/nmcli/devices.c | 23 ++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/man/nmcli.xml b/man/nmcli.xml index 764e5faca9..a8eaba8097 100644 --- a/man/nmcli.xml +++ b/man/nmcli.xml @@ -1436,15 +1436,23 @@ + --permanent yes no + up + down Set device properties. + + The property accepts a + option to persist the managed state to disk, and not only in runtime. The special + values and can be used to set the administrative + state of the device at the same time as the managed state. diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index 35ed5b6fd1..1547bd2ebf 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -855,7 +855,7 @@ usage(void) "delete | monitor | wifi | lldp }\n\n" " status\n\n" " show []\n\n" - " set [ifname] [autoconnect yes|no] [managed yes|no]\n\n" + " set [ifname] [autoconnect yes|no] [managed [--permanent] yes|no|up|down]\n\n" " connect \n\n" " reapply \n\n" " modify ([+|-]. )+\n\n" @@ -978,7 +978,7 @@ usage_device_set(void) "ARGUMENTS := DEVICE { PROPERTY [ PROPERTY ... ] }\n" "DEVICE := [ifname] \n" "PROPERTY := { autoconnect { yes | no } |\n" - " { managed { yes | no }\n" + " { managed [--permanent] { yes | no | up | down }\n" "\n" "Modify device properties.\n\n")); } @@ -2878,13 +2878,22 @@ do_device_set(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *ar } if (argc == 1 && nmc->complete) { - if (**argv == '-') - nmc_complete_strings(*argv, "--permanent"); - else - nmc_complete_bool(*argv); + nmc_complete_strings(*argv, + "true", + "yes", + "on", + "false", + "no", + "off", + "up", + "down", + "--permanent"); } - if (!nmc_string_to_bool(*argv, &val, &error)) { + if (matches(*argv, "up") || matches(*argv, "down")) { + flags |= NM_DEVICE_MANAGED_FLAGS_SET_ADMIN_STATE; + val = matches(*argv, "up") ? TRUE : FALSE; + } else if (!nmc_string_to_bool(*argv, &val, &error)) { g_string_printf(nmc->return_text, _("Error: 'managed': %s."), error->message); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; return;