mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 04:30:16 +01:00
core: set unspecified bond options to their default value
Otherwise if another connection was subsequently activated on a bond interface, and didn't specify all options, ones set for the previous connection could stay set for the new connection.
This commit is contained in:
parent
b9ddbe58f0
commit
b3f7b20a99
2 changed files with 28 additions and 15 deletions
|
|
@ -1228,25 +1228,22 @@ set_bond_attr (const char *iface, const char *attr, const char *value)
|
|||
char file[FILENAME_MAX];
|
||||
gboolean ret;
|
||||
|
||||
snprintf (file, sizeof(file), "/sys/class/net/%s/bonding/%s",
|
||||
iface, attr);
|
||||
|
||||
snprintf (file, sizeof (file), "/sys/class/net/%s/bonding/%s", iface, attr);
|
||||
ret = nm_utils_do_sysctl (file, value);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
nm_log_warn (LOGD_HW, "(%s): failed to set bonding attribute "
|
||||
"'%s' to '%s'", iface, attr, value);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_system_apply_bonding_config (NMSettingBond *s_bond)
|
||||
nm_system_apply_bonding_config (const char *iface, NMSettingBond *s_bond)
|
||||
{
|
||||
const char *name;
|
||||
guint32 i;
|
||||
const char **opts, **iter;
|
||||
|
||||
name = nm_setting_bond_get_interface_name (s_bond);
|
||||
g_assert (name);
|
||||
g_return_val_if_fail (iface != NULL, FALSE);
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
|
|
@ -1267,13 +1264,28 @@ nm_system_apply_bonding_config (NMSettingBond *s_bond)
|
|||
* the result is pretty much unforeseeable.
|
||||
*/
|
||||
|
||||
for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) {
|
||||
const char *key, *value;
|
||||
/* Set bonding options; if the setting didn't specify a value for the
|
||||
* option then use the default value to ensure there's no leakage of
|
||||
* options from any previous connections to this one.
|
||||
*/
|
||||
opts = nm_setting_bond_get_valid_options (s_bond);
|
||||
for (iter = opts; iter && *iter; iter++) {
|
||||
const char *value;
|
||||
gboolean is_default = FALSE;
|
||||
|
||||
if (!nm_setting_bond_get_option (s_bond, i, &key, &value))
|
||||
continue;
|
||||
value = nm_setting_bond_get_option_by_name (s_bond, *iter);
|
||||
if (!value) {
|
||||
value = nm_setting_bond_get_option_default (s_bond, *iter); /* use the default value */
|
||||
is_default = TRUE;
|
||||
}
|
||||
|
||||
set_bond_attr (name, key, value);
|
||||
nm_log_dbg (LOGD_DEVICE, "(%s): setting bond option '%s' to %s'%s'",
|
||||
iface,
|
||||
*iter,
|
||||
is_default ? "default " : "",
|
||||
value);
|
||||
|
||||
set_bond_attr (iface, *iter, value);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ gboolean nm_system_iface_set_mtu (int ifindex, guint32 mtu);
|
|||
|
||||
gboolean nm_system_iface_set_mac (int ifindex, const struct ether_addr *mac);
|
||||
|
||||
gboolean nm_system_apply_bonding_config (NMSettingBond *s_bond);
|
||||
gboolean nm_system_apply_bonding_config (const char *iface,
|
||||
NMSettingBond *s_bond);
|
||||
gboolean nm_system_add_bonding_master (const char *iface);
|
||||
|
||||
gboolean nm_system_iface_enslave (gint master_ifindex,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue