Commit b3f7b20a authored by Dan Williams's avatar Dan Williams

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.
parent b9ddbe58
......@@ -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;
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);
......@@ -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;
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;
if (!nm_setting_bond_get_option (s_bond, i, &key, &value))
nm_log_dbg (LOGD_DEVICE, "(%s): setting bond option '%s' to %s'%s'",
is_default ? "default " : "",
set_bond_attr (name, key, 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,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment