This parameter works as a threshold for the lacp runner to decide whether to set the carrier up or down.
Signed-off-by: Flavio Leitner fbl@redhat.com --- man/teamd.conf.5 | 7 +++++++ teamd/teamd_runner_lacp.c | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/man/teamd.conf.5 b/man/teamd.conf.5 index 06beb2e..f826f7b 100644 --- a/man/teamd.conf.5 +++ b/man/teamd.conf.5 @@ -120,6 +120,13 @@ System priority, value can be 0-65535. Default: .BR "255"
+.TP +.BR "runner.min_ports " (int) +Specifies the minimum number of ports that must be active before asserting carrier in the master interface, value can be 1-255. + +Default: +.BR "0" + .SH ETHTOOL LINK WATCH SPECIFIC OPTIONS .TP .BR "link_watch.delay_up "| " ports.PORTIFNAME.link_watch.delay_up " (int) diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c index 0763919..a2cee33 100644 --- a/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c @@ -116,6 +116,8 @@ struct lacp { #define LACP_CFG_DFLT_SYS_PRIO 0xffff bool fast_rate; #define LACP_CFG_DFLT_FAST_RATE false + int min_ports; +#define LACP_CFG_DFLT_MIN_PORTS 1 } cfg; struct teamd_balancer *tb; }; @@ -196,6 +198,19 @@ static int lacp_load_config(struct teamd_context *ctx, struct lacp *lacp) &tmp); lacp->cfg.fast_rate = err ? LACP_CFG_DFLT_FAST_RATE : !!tmp; teamd_log_dbg("Using fast_rate "%d".", lacp->cfg.fast_rate); + + err = json_unpack(ctx->config_json, "{s:{s:i}}", "runner", "min_ports", + &tmp); + if (err) { + lacp->cfg.min_ports = LACP_CFG_DFLT_MIN_PORTS; + } else if (tmp < 1 || tmp > UCHAR_MAX) { + teamd_log_err(""min_ports" value is out of its limits."); + return -EINVAL; + } else { + lacp->cfg.min_ports = tmp; + } + teamd_log_dbg("Using min_ports "%d".", lacp->cfg.min_ports); + return 0; }
@@ -363,8 +378,10 @@ static int lacp_update_carrier(struct lacp *lacp) struct teamd_port *tdport; struct lacp_port *lacp_port; struct team_option *option; + int ports_enabled; bool state;
+ ports_enabled = 0; teamd_for_each_tdport(tdport, lacp->ctx) { lacp_port = lacp_port_get(lacp, tdport); option = team_get_option(lacp_port->ctx->th, "np", "enabled", @@ -376,8 +393,9 @@ static int lacp_update_carrier(struct lacp *lacp) }
state = team_get_option_value_bool(option); - if (state) + if (state && ++ports_enabled >= lacp->cfg.min_ports) return lacp_set_carrier(lacp, true); + }
return lacp_set_carrier(lacp, false);