diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2022-06-24 00:30:04 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2022-06-24 00:30:04 +0200 |
commit | d51140d2abcde0a77b1bbc5d7be664161f498060 (patch) | |
tree | dc41e98a041110166f0fc421d03d2631aa87f519 | |
parent | 0cb971d1d6c7e267727cfaf26276b4cfc73685fb (diff) |
nmcli/connections: do not remove a bond option unless reset is allowed
If we're setting an option with no value given and no reset allowed,
let's just set the default value.
-rw-r--r-- | src/nmcli/connections.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 787ea25c9f..eda68139bb 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -4651,7 +4651,6 @@ set_bond_option(NmCli *nmc, GError **error) { NMSettingBond *s_bond; - gboolean success; gs_free char *name = NULL; char *p; @@ -4665,26 +4664,25 @@ set_bond_option(NmCli *nmc, } if (nm_str_is_empty(value)) { - nm_setting_bond_remove_option(s_bond, name); - success = TRUE; - } else - success = _nm_meta_setting_bond_add_option(NM_SETTING(s_bond), name, value, error); - - if (!success) - return FALSE; + if (allow_reset) { + nm_setting_bond_remove_option(s_bond, name); + return TRUE; + } + } else { + if (!_nm_meta_setting_bond_add_option(NM_SETTING(s_bond), name, value, error)) + return FALSE; + } - if (success) { - if (nm_streq(name, NM_SETTING_BOND_OPTION_MODE)) { - value = nmc_bond_validate_mode(value, error); - if (nm_streq(value, "active-backup")) { - enable_options(NM_SETTING_BOND_SETTING_NAME, - NM_SETTING_BOND_OPTIONS, - NM_MAKE_STRV("primary")); - } + if (nm_streq(name, NM_SETTING_BOND_OPTION_MODE)) { + value = nm_setting_bond_get_option_by_name(s_bond, name); + if (nm_streq(value, "active-backup")) { + enable_options(NM_SETTING_BOND_SETTING_NAME, + NM_SETTING_BOND_OPTIONS, + NM_MAKE_STRV("primary")); } } - return success; + return TRUE; } static gboolean |