summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2019-01-03 12:02:41 +0100
committerFrancesco Giudici <fgiudici@redhat.com>2019-01-10 09:52:02 +0100
commitabc40618f1bab6a347d0ec6abf39a4fb8ed3d563 (patch)
treecd577428efa95ec08217215ffe1d103d30810a29
parentede6b65abf6cf161d64c8826df0c5b41afd13a42 (diff)
downloadNetworkManager-fg/assume_bridge-rh1593939.tar.gz
device: when assuming a bridge ignore stp options if stp is disabledfg/assume_bridge-rh1593939
When STP is disabled, the bridge parameters 'priority', 'forward-delay', 'hello-time' and 'max-age' are irrelevant. We already skip them when loading a connection profile from a ifcfg file. Do the same when generating a connection from a configured device, in order to possibly assume the connection.
-rw-r--r--src/devices/nm-device-bridge.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 02c5df0c51..4c8921c071 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -173,33 +173,34 @@ typedef struct {
uint nm_default;
bool default_if_zero;
bool user_hz_compensate;
+ bool only_with_stp;
} Option;
static const Option master_options[] = {
- { NM_SETTING_BRIDGE_STP, "stp_state",
+ { NM_SETTING_BRIDGE_STP, "stp_state", /* this must stay as the first item */
0, 1, 1,
- FALSE, FALSE },
+ FALSE, FALSE, FALSE },
{ NM_SETTING_BRIDGE_PRIORITY, "priority",
0, G_MAXUINT16, 0x8000,
- TRUE, FALSE },
+ TRUE, FALSE, TRUE },
{ NM_SETTING_BRIDGE_FORWARD_DELAY, "forward_delay",
0, NM_BR_MAX_FORWARD_DELAY, 15,
- TRUE, TRUE },
+ TRUE, TRUE, TRUE},
{ NM_SETTING_BRIDGE_HELLO_TIME, "hello_time",
0, NM_BR_MAX_HELLO_TIME, 2,
- TRUE, TRUE },
+ TRUE, TRUE, TRUE },
{ NM_SETTING_BRIDGE_MAX_AGE, "max_age",
0, NM_BR_MAX_MAX_AGE, 20,
- TRUE, TRUE },
+ TRUE, TRUE, TRUE },
{ NM_SETTING_BRIDGE_AGEING_TIME, "ageing_time",
NM_BR_MIN_AGEING_TIME, NM_BR_MAX_AGEING_TIME, 300,
- TRUE, TRUE },
+ TRUE, TRUE, FALSE },
{ NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, "group_fwd_mask",
0, 0xFFFF, 0,
- TRUE, FALSE },
+ TRUE, FALSE, FALSE },
{ NM_SETTING_BRIDGE_MULTICAST_SNOOPING, "multicast_snooping",
0, 1, 1,
- FALSE, FALSE },
+ FALSE, FALSE, FALSE },
{ NULL, NULL }
};
@@ -300,16 +301,29 @@ update_connection (NMDevice *device, NMConnection *connection)
NMSettingBridge *s_bridge = nm_connection_get_setting_bridge (connection);
int ifindex = nm_device_get_ifindex (device);
const Option *option;
+ gs_free char *stp = NULL;
+ int stp_value;
if (!s_bridge) {
s_bridge = (NMSettingBridge *) nm_setting_bridge_new ();
nm_connection_add_setting (connection, (NMSetting *) s_bridge);
}
- for (option = master_options; option->name; option++) {
+ option = master_options;
+ nm_assert (nm_streq (option->sysname, "stp_state"));
+
+ stp = nm_platform_sysctl_master_get_option (nm_device_get_platform (device), ifindex, option->sysname);
+ stp_value = _nm_utils_ascii_str_to_int64 (stp, 10, option->nm_min, option->nm_max, option->nm_default);
+ g_object_set (s_bridge, option->name, stp_value, NULL);
+ option++;
+
+ for (; option->name; option++) {
gs_free char *str = nm_platform_sysctl_master_get_option (nm_device_get_platform (device), ifindex, option->sysname);
uint value;
+ if (!stp_value && option->only_with_stp)
+ continue;
+
if (str) {
/* See comments in set_sysfs_uint() about centiseconds. */
if (option->user_hz_compensate) {