diff options
| author | Michael Biebl <biebl@debian.org> | 2023-02-10 11:50:34 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2023-02-10 11:50:34 +0100 |
| commit | 1372848511cb896b80b51ed1a3e9606bd9816631 (patch) | |
| tree | 674792b9385bdef935988894b45f06b2af39f88c /src/libnm-core-impl/nm-setting-bond.c | |
| parent | 40ec077ea305994c1fc2130add6787ca0c73e2c6 (diff) | |
New upstream version 1.42.0 upstream/1.42.0
Diffstat (limited to 'src/libnm-core-impl/nm-setting-bond.c')
| -rw-r--r-- | src/libnm-core-impl/nm-setting-bond.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/src/libnm-core-impl/nm-setting-bond.c b/src/libnm-core-impl/nm-setting-bond.c index 18b6fefb..54030e0b 100644 --- a/src/libnm-core-impl/nm-setting-bond.c +++ b/src/libnm-core-impl/nm-setting-bond.c @@ -70,6 +70,7 @@ static const char *const valid_options_lst[] = { NM_SETTING_BOND_OPTION_ARP_INTERVAL, NM_SETTING_BOND_OPTION_ARP_IP_TARGET, NM_SETTING_BOND_OPTION_ARP_VALIDATE, + NM_SETTING_BOND_OPTION_BALANCE_SLB, NM_SETTING_BOND_OPTION_PRIMARY, NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, @@ -195,6 +196,7 @@ static NM_UTILS_STRING_TABLE_LOOKUP_STRUCT_DEFINE( {NM_SETTING_BOND_OPTION_ARP_IP_TARGET, {"", NM_BOND_OPTION_TYPE_IP}}, {NM_SETTING_BOND_OPTION_ARP_VALIDATE, {"none", NM_BOND_OPTION_TYPE_BOTH, 0, 6, _option_default_strv_arp_validate}}, + {NM_SETTING_BOND_OPTION_BALANCE_SLB, {"0", NM_BOND_OPTION_TYPE_INT, 0, 1}}, {NM_SETTING_BOND_OPTION_DOWNDELAY, {"0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT}}, {NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, {"none", NM_BOND_OPTION_TYPE_BOTH, 0, 2, _option_default_strv_fail_over_mac}}, @@ -344,6 +346,17 @@ _bond_get_option_normalized(NMSettingBond *self, const char *option, gboolean ge value = _bond_get_option(self, NM_SETTING_BOND_OPTION_PRIMARY); if (!value) value = _bond_get_option(self, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE); + } else if (nm_streq(option, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY)) { + if (_nm_utils_ascii_str_to_int64( + _bond_get_option(self, NM_SETTING_BOND_OPTION_BALANCE_SLB), + 10, + 0, + 1, + -1) + == 1) { + /* balance-slb implies vlan+srcmac */ + return "5"; + } } else value = _bond_get_option(self, option); @@ -506,7 +519,7 @@ validate_ip(const char *name, const char *value, GError **error) return FALSE; } for (i = 0; addrs[i]; i++) { - if (!nm_utils_parse_inaddr_bin(AF_INET, addrs[i], NULL, NULL)) { + if (!nm_inet_parse_bin(AF_INET, addrs[i], NULL, NULL)) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -588,7 +601,7 @@ handle_error: /** * nm_setting_bond_validate_option: * @name: the name of the option to validate - * @value (allow-none): the value of the option to validate. + * @value: (allow-none): the value of the option to validate. * * Checks whether @name is a valid bond option and @value is a valid value for * the @name. If @value is %NULL, the function only validates the option name. @@ -840,6 +853,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) const char *arp_ip_target = NULL; const char *lacp_rate; const char *primary; + const char *s; NMBondMode bond_mode; guint i; const NMUtilsNamedValue *n; @@ -1067,6 +1081,32 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + s = _bond_get_option(self, NM_SETTING_BOND_OPTION_BALANCE_SLB); + if (s && _atoi(s) > 0) { + if (bond_mode != NM_BOND_MODE_XOR) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("%s requires bond mode \"%s\""), + NM_SETTING_BOND_OPTION_BALANCE_SLB, + "balance-xor"); + g_prefix_error(error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); + return FALSE; + } + s = _bond_get_option(self, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY); + if (s + && _nm_setting_bond_xmit_hash_policy_from_string(s) + != NM_BOND_XMIT_HASH_POLICY_VLAN_SRCMAC) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("%s requires xmit_hash_policy \"vlan+srcmac\""), + NM_SETTING_BOND_OPTION_BALANCE_SLB); + g_prefix_error(error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); + return FALSE; + } + } + if (!_nm_connection_verify_required_interface_name(connection, error)) return FALSE; @@ -1233,7 +1273,7 @@ nm_setting_bond_class_init(NMSettingBondClass *klass) setting_class->verify = verify; /** - * NMSettingBond:options: (type GHashTable(utf8,utf8)): + * NMSettingBond:options: (type GHashTable(utf8,utf8)) * * Dictionary of key/value pairs of bonding options. Both keys and values * must be strings. Option names must contain only alphanumeric characters @@ -1273,7 +1313,8 @@ nm_setting_bond_class_init(NMSettingBondClass *klass) */ _nm_properties_override_dbus(properties_override, "interface-name", - &nm_sett_info_propert_type_deprecated_interface_name); + &nm_sett_info_propert_type_deprecated_interface_name, + .dbus_deprecated = TRUE, ); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); |