From: Felix Fietkau Date: Tue, 24 Aug 2021 15:16:05 +0000 (+0200) Subject: bridge: tune default stp parameters X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=454e9c33c90691d5bea12263f1801a7dc38c20b1;p=project%2Fnetifd.git bridge: tune default stp parameters The default forwarding delay 2 is broken and makes STP non-functional by default. The kernel's default of 15 is rather long. This commit changes makes the timer settings more aggressive than the kernel's default while still being consistent and allowing proper convergence for a network diameter up to 4 Signed-off-by: Felix Fietkau --- diff --git a/bridge.c b/bridge.c index 15e09dd..2ce5c2b 100644 --- a/bridge.c +++ b/bridge.c @@ -339,10 +339,8 @@ static void bridge_stp_notify(struct bridge_state *bst) if (cfg->stp_proto) blobmsg_add_string(&b, "proto", cfg->stp_proto); blobmsg_add_u32(&b, "forward_delay", cfg->forward_delay); - if (cfg->flags & BRIDGE_OPT_HELLO_TIME) - blobmsg_add_u32(&b, "hello_time", cfg->hello_time); - if (cfg->flags & BRIDGE_OPT_MAX_AGE) - blobmsg_add_u32(&b, "max_age", cfg->max_age); + blobmsg_add_u32(&b, "hello_time", cfg->hello_time); + blobmsg_add_u32(&b, "max_age", cfg->max_age); if (cfg->flags & BRIDGE_OPT_AGEING_TIME) blobmsg_add_u32(&b, "ageing_time", cfg->ageing_time); netifd_ubus_device_notify("stp_init", b.head, 1000); @@ -1045,7 +1043,6 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) memset(cfg, 0, sizeof(*cfg)); cfg->stp = false; cfg->stp_kernel = false; - cfg->forward_delay = 2; cfg->robustness = 2; cfg->igmp_snoop = false; cfg->multicast_querier = false; @@ -1057,6 +1054,10 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) cfg->priority = 0x7FFF; cfg->vlan_filtering = false; + cfg->forward_delay = 8; + cfg->max_age = 10; + cfg->hello_time = 1; + if ((cur = tb[BRIDGE_ATTR_STP])) cfg->stp = blobmsg_get_bool(cur); @@ -1106,15 +1107,11 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) cfg->flags |= BRIDGE_OPT_AGEING_TIME; } - if ((cur = tb[BRIDGE_ATTR_HELLO_TIME])) { + if ((cur = tb[BRIDGE_ATTR_HELLO_TIME])) cfg->hello_time = blobmsg_get_u32(cur); - cfg->flags |= BRIDGE_OPT_HELLO_TIME; - } - if ((cur = tb[BRIDGE_ATTR_MAX_AGE])) { + if ((cur = tb[BRIDGE_ATTR_MAX_AGE])) cfg->max_age = blobmsg_get_u32(cur); - cfg->flags |= BRIDGE_OPT_MAX_AGE; - } if ((cur = tb[BRIDGE_ATTR_BRIDGE_EMPTY])) cfg->bridge_empty = blobmsg_get_bool(cur); diff --git a/system-linux.c b/system-linux.c index e9a19f7..85942a5 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1276,21 +1276,17 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg) snprintf(buf, sizeof(buf), "%d", cfg->priority); system_bridge_set_priority(bridge, buf); + snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->hello_time)); + system_bridge_set_hello_time(bridge, buf); + + snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->max_age)); + system_bridge_set_max_age(bridge, buf); + if (cfg->flags & BRIDGE_OPT_AGEING_TIME) { snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->ageing_time)); system_bridge_set_ageing_time(bridge, buf); } - if (cfg->flags & BRIDGE_OPT_HELLO_TIME) { - snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->hello_time)); - system_bridge_set_hello_time(bridge, buf); - } - - if (cfg->flags & BRIDGE_OPT_MAX_AGE) { - snprintf(buf, sizeof(buf), "%lu", sec_to_jiffies(cfg->max_age)); - system_bridge_set_max_age(bridge, buf); - } - return 0; } diff --git a/system.h b/system.h index c5c4f23..b6eda7e 100644 --- a/system.h +++ b/system.h @@ -108,14 +108,12 @@ extern const struct uci_blob_param_list ipip6_data_attr_list; extern const struct uci_blob_param_list fmr_data_attr_list; enum bridge_opt { - /* stp and forward delay always set */ + /* stp, forward delay, max age and hello time are always set */ BRIDGE_OPT_AGEING_TIME = (1 << 0), - BRIDGE_OPT_HELLO_TIME = (1 << 1), - BRIDGE_OPT_MAX_AGE = (1 << 2), - BRIDGE_OPT_ROBUSTNESS = (1 << 3), - BRIDGE_OPT_QUERY_INTERVAL = (1 << 4), - BRIDGE_OPT_QUERY_RESPONSE_INTERVAL = (1 << 5), - BRIDGE_OPT_LAST_MEMBER_INTERVAL = (1 << 6), + BRIDGE_OPT_ROBUSTNESS = (1 << 1), + BRIDGE_OPT_QUERY_INTERVAL = (1 << 2), + BRIDGE_OPT_QUERY_RESPONSE_INTERVAL = (1 << 3), + BRIDGE_OPT_LAST_MEMBER_INTERVAL = (1 << 4), }; struct bridge_config {