diff options
author | Antonio Cardace <acardace@redhat.com> | 2020-03-03 11:36:16 +0100 |
---|---|---|
committer | Antonio Cardace <acardace@redhat.com> | 2020-03-06 10:39:00 +0100 |
commit | b868fee9cb7b09b1e5d1c269f0591cb036813d79 (patch) | |
tree | b5ceae12ab7caab5c5471f0e967fc08ca7da9660 | |
parent | 9bd07336ef16f014b35f66a7d0d03bc49703b039 (diff) | |
download | NetworkManager-b868fee9cb7b09b1e5d1c269f0591cb036813d79.tar.gz |
nm-setting-bond: add API to libnm to get the normalized bond option value
Add 'nm_setting_bond_get_option_normalized()', the purpose of this API
is to retrieve a bond option normalized value which is the option that
NetworkManager will actually apply to the bond when activating the
connection, this takes into account default values for some options that
NM assumes.
For example, if you create a connection:
$ nmcli c add type bond con-name nm-bond ifname bond0 bond.options mode=0
Calling 'nm_setting_bond_get_option_normalized(s_bond, "miimon")' would
return "100" as even if not specified NetworkManager enables miimon for
bond connections.
Another example:
$ nmcli c add type bond con-name nm-bond ifname bond0 bond.options mode=0,arp_interval=100
Calling 'nm_setting_bond_get_option_normalized(s_bond, "miimon")' would
return NULL in this case because NetworkManager disables miimon if
'arp_interval' is set explicitly but 'miimon' is not.
-rw-r--r-- | libnm-core/nm-setting-bond.c | 23 | ||||
-rw-r--r-- | libnm-core/nm-setting-bond.h | 4 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index 0d34086ba9..f53f2c8cf2 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -662,6 +662,29 @@ nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name) } /** + * nm_setting_bond_get_option_normalized: + * @setting: the #NMSettingBond + * @name: the name of the option + * + * Since: 1.24 + * + * Returns: the value of the bond option after normalization, which is what NetworkManager + * will actually apply when activating the connection. %NULL if the option won't be applied + * to the connection. + **/ +const char * +nm_setting_bond_get_option_normalized (NMSettingBond *setting, + const char *name) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL); + g_return_val_if_fail (name, NULL); + + return _bond_get_option_normalized (setting, + name, + FALSE); +} + +/** * nm_setting_bond_get_option_type: * @setting: the #NMSettingBond * @name: the name of the option diff --git a/libnm-core/nm-setting-bond.h b/libnm-core/nm-setting-bond.h index c17babdc84..fc2a37353d 100644 --- a/libnm-core/nm-setting-bond.h +++ b/libnm-core/nm-setting-bond.h @@ -94,6 +94,10 @@ const char **nm_setting_bond_get_valid_options (NMSettingBond *setting); const char * nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name); +NM_AVAILABLE_IN_1_24 +const char * nm_setting_bond_get_option_normalized (NMSettingBond *setting, + const char *name); + G_END_DECLS #endif /* __NM_SETTING_BOND_H__ */ diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 9229a1fc79..ce266bec60 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1678,6 +1678,7 @@ global: nm_secret_agent_old_get_dbus_connection; nm_secret_agent_old_get_dbus_name_owner; nm_secret_agent_old_get_main_context; + nm_setting_bond_get_option_normalized; nm_setting_vrf_get_table; nm_setting_vrf_get_type; nm_setting_vrf_new; |