Skip to content

Commit 32b0b89

Browse files
louis-6windkuba-moo
authored andcommitted
bonding: 3ad: add lacp_strict configuration knob
When an 802.3ad (LACP) bonding interface has no slaves in the collecting/distributing state, the bonding master still reports carrier as up as long as at least 'min_links' slaves have carrier. In this situation, only one slave is effectively used for TX/RX, while traffic received on other slaves is dropped. Upper-layer daemons therefore consider the interface operational, even though traffic may be blackholed if the lack of LACP negotiation means the partner is not ready to deal with traffic. Introduce a configuration knob to control this behavior. It allows the bonding master to assert carrier only when at least 'min_links' slaves are in Collecting_Distributing state. The default mode preserves the existing behavior. This patch only introduces the knob; its behavior is implemented in the subsequent commit. Fixes: 655f891 ("bonding: add min links parameter to 802.3ad") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> Acked-by: Jay Vosburgh <jv@jvosburgh.net> Link: https://patch.msgid.link/20260603150331.1919611-4-louis.scalbert@6wind.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3630379 commit 32b0b89

9 files changed

Lines changed: 73 additions & 0 deletions

File tree

Documentation/netlink/specs/rt-link.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ attribute-sets:
13561356
-
13571357
name: broadcast-neigh
13581358
type: u8
1359+
-
1360+
name: lacp-strict
1361+
type: u8
13591362
-
13601363
name: bond-ad-info-attrs
13611364
name-prefix: ifla-bond-ad-info-

Documentation/networking/bonding.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,29 @@ min_links
619619
aggregator cannot be active without at least one available link,
620620
setting this option to 0 or to 1 has the exact same effect.
621621

622+
lacp_strict
623+
624+
Specifies the fallback behavior of a bonding when LACP negotiation
625+
fails on all slave links, i.e. when no slave is in the
626+
Collecting_Distributing state, while at least `min_links` link still
627+
reports carrier up.
628+
629+
This option is only applicable to 802.3ad mode (mode 4).
630+
631+
Valid values are:
632+
633+
off or 0
634+
One interface of the bond is selected to be active, in order to
635+
facilitate communication with peer devices that do not implement
636+
LACP.
637+
638+
on or 1
639+
Interfaces are only permitted to be made active if they have an
640+
active LACP partner and have successfully reached
641+
Collecting_Distributing state.
642+
643+
The default value is 0 (off).
644+
622645
mode
623646

624647
Specifies one of the bonding policies. The default is

drivers/net/bonding/bond_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6457,6 +6457,7 @@ static int __init bond_check_params(struct bond_params *params)
64576457
params->ad_user_port_key = ad_user_port_key;
64586458
params->coupled_control = 1;
64596459
params->broadcast_neighbor = 0;
6460+
params->lacp_strict = 0;
64606461
if (packets_per_slave > 0) {
64616462
params->reciprocal_packets_per_slave =
64626463
reciprocal_value(packets_per_slave);

drivers/net/bonding/bond_netlink.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
143143
[IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED },
144144
[IFLA_BOND_COUPLED_CONTROL] = { .type = NLA_U8 },
145145
[IFLA_BOND_BROADCAST_NEIGH] = { .type = NLA_U8 },
146+
[IFLA_BOND_LACP_STRICT] = { .type = NLA_U8 },
146147
};
147148

148149
static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = {
@@ -599,6 +600,16 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
599600
return err;
600601
}
601602

603+
if (data[IFLA_BOND_LACP_STRICT]) {
604+
int fallback_mode = nla_get_u8(data[IFLA_BOND_LACP_STRICT]);
605+
606+
bond_opt_initval(&newval, fallback_mode);
607+
err = __bond_opt_set(bond, BOND_OPT_LACP_STRICT, &newval,
608+
data[IFLA_BOND_LACP_STRICT], extack);
609+
if (err)
610+
return err;
611+
}
612+
602613
return 0;
603614
}
604615

@@ -671,6 +682,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
671682
nla_total_size(sizeof(struct in6_addr)) * BOND_MAX_NS_TARGETS +
672683
nla_total_size(sizeof(u8)) + /* IFLA_BOND_COUPLED_CONTROL */
673684
nla_total_size(sizeof(u8)) + /* IFLA_BOND_BROADCAST_NEIGH */
685+
nla_total_size(sizeof(u8)) + /* IFLA_BOND_LACP_STRICT */
674686
0;
675687
}
676688

@@ -838,6 +850,10 @@ static int bond_fill_info(struct sk_buff *skb,
838850
bond->params.broadcast_neighbor))
839851
goto nla_put_failure;
840852

853+
if (nla_put_u8(skb, IFLA_BOND_LACP_STRICT,
854+
bond->params.lacp_strict))
855+
goto nla_put_failure;
856+
841857
if (BOND_MODE(bond) == BOND_MODE_8023AD) {
842858
struct ad_info info;
843859

drivers/net/bonding/bond_options.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ static int bond_option_lacp_active_set(struct bonding *bond,
6868
const struct bond_opt_value *newval);
6969
static int bond_option_lacp_rate_set(struct bonding *bond,
7070
const struct bond_opt_value *newval);
71+
static int bond_option_lacp_strict_set(struct bonding *bond,
72+
const struct bond_opt_value *newval);
7173
static int bond_option_ad_select_set(struct bonding *bond,
7274
const struct bond_opt_value *newval);
7375
static int bond_option_queue_id_set(struct bonding *bond,
@@ -162,6 +164,12 @@ static const struct bond_opt_value bond_lacp_rate_tbl[] = {
162164
{ NULL, -1, 0},
163165
};
164166

167+
static const struct bond_opt_value bond_lacp_strict_tbl[] = {
168+
{ "off", 0, BOND_VALFLAG_DEFAULT},
169+
{ "on", 1, 0},
170+
{ NULL, -1, 0 }
171+
};
172+
165173
static const struct bond_opt_value bond_ad_select_tbl[] = {
166174
{ "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT},
167175
{ "bandwidth", BOND_AD_BANDWIDTH, 0},
@@ -363,6 +371,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
363371
.values = bond_lacp_rate_tbl,
364372
.set = bond_option_lacp_rate_set
365373
},
374+
[BOND_OPT_LACP_STRICT] = {
375+
.id = BOND_OPT_LACP_STRICT,
376+
.name = "lacp_strict",
377+
.desc = "Define the LACP fallback mode when no slaves have negotiated",
378+
.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
379+
.values = bond_lacp_strict_tbl,
380+
.set = bond_option_lacp_strict_set
381+
},
366382
[BOND_OPT_MINLINKS] = {
367383
.id = BOND_OPT_MINLINKS,
368384
.name = "min_links",
@@ -1685,6 +1701,16 @@ static int bond_option_lacp_rate_set(struct bonding *bond,
16851701
return 0;
16861702
}
16871703

1704+
static int bond_option_lacp_strict_set(struct bonding *bond,
1705+
const struct bond_opt_value *newval)
1706+
{
1707+
netdev_dbg(bond->dev, "Setting LACP fallback to %s (%llu)\n",
1708+
newval->string, newval->value);
1709+
bond->params.lacp_strict = newval->value;
1710+
1711+
return 0;
1712+
}
1713+
16881714
static int bond_option_ad_select_set(struct bonding *bond,
16891715
const struct bond_opt_value *newval)
16901716
{

include/net/bond_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ enum {
7979
BOND_OPT_COUPLED_CONTROL,
8080
BOND_OPT_BROADCAST_NEIGH,
8181
BOND_OPT_ACTOR_PORT_PRIO,
82+
BOND_OPT_LACP_STRICT,
8283
BOND_OPT_LAST
8384
};
8485

include/net/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct bond_params {
129129
int peer_notif_delay;
130130
int lacp_active;
131131
int lacp_fast;
132+
int lacp_strict;
132133
unsigned int min_links;
133134
int ad_select;
134135
char primary[IFNAMSIZ];

include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ enum {
16031603
IFLA_BOND_NS_IP6_TARGET,
16041604
IFLA_BOND_COUPLED_CONTROL,
16051605
IFLA_BOND_BROADCAST_NEIGH,
1606+
IFLA_BOND_LACP_STRICT,
16061607
__IFLA_BOND_MAX,
16071608
};
16081609

tools/include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,7 @@ enum {
15271527
IFLA_BOND_NS_IP6_TARGET,
15281528
IFLA_BOND_COUPLED_CONTROL,
15291529
IFLA_BOND_BROADCAST_NEIGH,
1530+
IFLA_BOND_LACP_STRICT,
15301531
__IFLA_BOND_MAX,
15311532
};
15321533

0 commit comments

Comments
 (0)