Skip to contentSkip to conversation

bonding: 3ad: fix carrier state with no usable slaves

PATCH Applied Louis Scalbert 5 participants 15 messages Jun 3 – Jun 10

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v8 cover bonding: 3ad: fix carrier state with no usable slaves

Hi everyone,

This series addresses a blackholing issue and a subsequent link-flapping issue in the 802.3ad bonding driver when dealing with inactive slaves and the min_links parameter.

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.

This patchset introduces an optional behavior, widely adopted across the industry, to address this issue. It consists of bringing the bonding master interface down to signal to upper-layer processes that it is not usable.

This patchset depends on the following iproute2 change:
ip/bond: add lacp_strict support

Patch 1 adds the missing IFLA_BOND_BROADCAST_NEIGH in if_link UAPI header.

Patch 2 adds missing broadcast-neigh to YAML rt-link specs.

Patch 3 introduces the lacp_strict configuration knob, which is applied in the subsequent patch. The default (off) mode preserves the existing behavior, while the strict mode (on) is intended to force the bonding master carrier down in this situation.

Patch 4 addresses the core issue when lacp_strict is set to strict. It ensures that carrier is asserted only when at least 'min_links' slaves are in the Collecting/Distributing state.

Patch 5 fixes a side effect of the previous patch. Tightening the carrier logic exposes a state persistence bug: when a physical link goes down, the LACP collecting/distributing flags remain set. When the link returns, the interface briefly hallucinates that it is ready, bounces the carrier up, and then drops it again once LACP renegotiation starts. Fix by resetting Collecting and Distributing state as soon as the link goes down.

Patch 6 adds a test for bonding lacp_strict both modes.

Changelog:

v7 -> v8
- Patch 3: addressed the Sashiko review comments, as requested by Simon Horman. When transitioning to DETACHED Mux state, reset Collecting / Distributing so the bonding carrier state is correctly re-evaluated. Also, re-evaluate the bonding carrier state when moving from Distributing to Collecting Mux state (coupled_control disabled).

v6 -> v7
- Add patch 1: sync missed IFLA_BOND_BROADCAST_NEIGH in if_link UAPI header.
- Add patch 2: add missed broadcast-neigh to YAML rt-link specs.
- Patch 3 (was patch 1 in v6): add lacp-strict to YAML rt-link specs and IFLA_BOND_LACP_STRICT to if_link UAPI header.
- Patch 6 (was patch 4 in v6): move bond_lacp_strict.sh in Makefile to preserve the sort order.

v5 -> v6
- Patch 3: the v5 patch was compliant with 802.1ax-2020, but the target specification is 802.1ax-2014. The fix has been reworked accordingly. Collecting and Distributing were not cleared on port down because the Receive state machine was not clearing the Partner Sync flag.

v4 -> v5
- Patch 4: replace the use of netem, which is not included in the bonding selftests configuration. Instead, use a dedicated netns to forward frames between the partner and DUT. The partner and DUT are bridged within that netns. Since Linux bridges do not forward LACP special frames by default, group_fwd_mask is configured on bridge interfaces to allow them.

v3 -> v4
- Rename the configuration knob to lacp_strict on/off instead of lacp_fallback legacy/strict.
- Patch 1: change the command documentation accordingly and wrap text at approximately 75 columns.
- Use "usable" wording instead "valid" for LACP Collecting / Distributing state in code and commit log.
- Patch 2: test collecting and distributing state regardless of coupled_control
- Patch 3: Reworked because removing the SELECTED flag was not compliant with 802.1AX. Instead, to transition to the WAITING state on port disabled, except when already in the DETACHED state. And remove Collecting and Distributing state in WAITING state.
- Patch 4 is removed. It was a fix for patch 3 but it is no more needed since patch 3 was reworked.

v2 -> v3
- Add an initial patch introducing the lacp_fallback configuration knob (no behavior change yet).
- Patch 2 (was patch 1 in v2): apply the new behavior only when lacp_fallback is set to strict, and re-evaluate the bonding master carrier when the setting changes.

v1 -> v2
- Patch 1: split a comment line that exceeded 80 characters.
- Move the change from patch 2 in __agg_ports_are_ready() into a third patch, as it is actually a side effect of the fix introduced in patch 2.
- Patch 2: Expand the commit message and add a code comment describing the change in ad_port_selection_logic().
- Patch 3: Check the READY_N flag only on ports in the WAITING state, rather than on all enabled ports. This more closely matches 802.3ad.

Louis Scalbert (6):
tools: missed broadcast_neigh if_link uapi header
netlink: specs: rt-link: missed broadcast-neigh
bonding: 3ad: add lacp_strict configuration knob
bonding: 3ad: fix carrier when no usable slaves
bonding: 3ad: fix mux port state on oper down
selftests: bonding: add test for lacp_strict mode

 Documentation/netlink/specs/rt-link.yaml      |   6 +
 Documentation/networking/bonding.rst          |  23 ++
 drivers/net/bonding/bond_3ad.c                |  27 +-
 drivers/net/bonding/bond_main.c               |   1 +
 drivers/net/bonding/bond_netlink.c            |  16 +
 drivers/net/bonding/bond_options.c            |  27 ++
 include/net/bond_options.h                    |   1 +
 include/net/bonding.h                         |   1 +
 include/uapi/linux/if_link.h                  |   1 +
 tools/include/uapi/linux/if_link.h            |   2 +
 .../selftests/drivers/net/bonding/Makefile    |   1 +
 .../drivers/net/bonding/bond_lacp_strict.sh   | 347 ++++++++++++++++++
 12 files changed, 450 insertions(+), 3 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_lacp_strict.sh
Signature · 1 line
2.39.2
#1 lore raw

PATCH v8 1/6 tools: missed broadcast_neigh if_link uapi header

Add missing IFLA_BOND_BROADCAST_NEIGH in if_link uapi header.

Fixes 3d98ee52659c ("net: bonding: add broadcast_neighbor netlink option")
---
 tools/include/uapi/linux/if_link.h | 1 +
 1 file changed, 1 insertion(+)
tools/include/uapi/linux/if_link.h +1 -0
index 7e46ca4cd31b..97a2d4411534 100644
@@ -1526,6 +1526,7 @@ enum {
 	IFLA_BOND_MISSED_MAX,
 	IFLA_BOND_NS_IP6_TARGET,
 	IFLA_BOND_COUPLED_CONTROL,
+	IFLA_BOND_BROADCAST_NEIGH,
 	__IFLA_BOND_MAX,
 };
 
Signature · 1 line
2.39.2
maintainer
#2 lore raw

Re: [PATCH net v8 1/6] tools: missed broadcast_neigh if_link uapi header

Quoted 4 lines · Louis Scalbert

Add missing IFLA_BOND_BROADCAST_NEIGH in if_link uapi header.

Fixes 3d98ee52659c ("net: bonding: add broadcast_neighbor netlink option")

I'm a bit confused, I see IFLA_BOND_BROADCAST_NEIGH already in
the net tree, added by:

commit 3d98ee52659c3f1d3913ae5b97f7743c5247752c

Author: Tonghao Zhang <[email protected]>
Date:   Fri Jun 27 21:49:29 2025 +0800

net: bonding: add broadcast_neighbor netlink option

-J

Quoted 19 lines

---
tools/include/uapi/linux/if_link.h | 1 +

1 file changed, 1 insertion(+)
tools/include/uapi/linux/if_link.h +1 -0
index 7e46ca4cd31b..97a2d4411534 100644
@@ -1526,6 +1526,7 @@ enum {
 	IFLA_BOND_MISSED_MAX,
 	IFLA_BOND_NS_IP6_TARGET,
 	IFLA_BOND_COUPLED_CONTROL,
+	IFLA_BOND_BROADCAST_NEIGH,
 	__IFLA_BOND_MAX,
 };
 
Signature · 1 line
2.39.2
maintainer
#3 lore raw

Re: [PATCH net v8 1/6] tools: missed broadcast_neigh if_link uapi header

Quoted 9 lines · Jay Vosburgh
Quoted 4 lines · Louis Scalbert

Add missing IFLA_BOND_BROADCAST_NEIGH in if_link uapi header.

Fixes 3d98ee52659c ("net: bonding: add broadcast_neighbor netlink option")

I'm a bit confused, I see IFLA_BOND_BROADCAST_NEIGH already in
the net tree, added by:

	Never mind, I'm a doofus and missed the "tools/" part.

	-J
Quoted 29 lines

commit 3d98ee52659c3f1d3913ae5b97f7743c5247752c

Author: Tonghao Zhang <[email protected]>
Date:   Fri Jun 27 21:49:29 2025 +0800

net: bonding: add broadcast_neighbor netlink option

	-J
Quoted 19 lines

---
tools/include/uapi/linux/if_link.h | 1 +

1 file changed, 1 insertion(+)
tools/include/uapi/linux/if_link.h +1 -0
index 7e46ca4cd31b..97a2d4411534 100644
@@ -1526,6 +1526,7 @@ enum {
 	IFLA_BOND_MISSED_MAX,
 	IFLA_BOND_NS_IP6_TARGET,
 	IFLA_BOND_COUPLED_CONTROL,
+	IFLA_BOND_BROADCAST_NEIGH,
 	__IFLA_BOND_MAX,
 };
 
Signature · 1 line
2.39.2
#4 lore raw

PATCH v8 2/6 netlink: specs: rt-link: missed broadcast-neigh

In reply to Louis Scalbert

Add missed broadcast-neigh.

Fixes 3d98ee52659c ("net: bonding: add broadcast_neighbor netlink option")
---
 Documentation/netlink/specs/rt-link.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/netlink/specs/rt-link.yaml +3 -0
index f23aa5f229c5..484e0a97b653 100644
@@ -1351,6 +1351,9 @@ attribute-sets:
       -
         name: coupled-control
         type: u8
+      -
+        name: broadcast-neigh
+        type: u8
   -
     name: bond-ad-info-attrs
     name-prefix: ifla-bond-ad-info-
Signature · 1 line
2.39.2
#5 lore raw

PATCH v8 3/6 bonding: 3ad: add lacp_strict configuration knob

In reply to Louis Scalbert

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 655f8919d549 ("bonding: add min links parameter to 802.3ad")
---
 Documentation/netlink/specs/rt-link.yaml |  3 +++
 Documentation/networking/bonding.rst     | 23 +++++++++++++++++++++
 drivers/net/bonding/bond_main.c          |  1 +
 drivers/net/bonding/bond_netlink.c       | 16 +++++++++++++++
 drivers/net/bonding/bond_options.c       | 26 ++++++++++++++++++++++++
 include/net/bond_options.h               |  1 +
 include/net/bonding.h                    |  1 +
 include/uapi/linux/if_link.h             |  1 +
 tools/include/uapi/linux/if_link.h       |  1 +
 9 files changed, 73 insertions(+)
Documentation/netlink/specs/rt-link.yaml +3 -0
index 484e0a97b653..644a8bd7b93c 100644
@@ -1354,6 +1354,9 @@ attribute-sets:
       -
         name: broadcast-neigh
         type: u8
+      -
+        name: lacp-strict
+        type: u8
   -
     name: bond-ad-info-attrs
     name-prefix: ifla-bond-ad-info-
Documentation/networking/bonding.rst +23 -0
index e700bf1d095c..33ca5afafdf6 100644
@@ -619,6 +619,29 @@ min_links
 	aggregator cannot be active without at least one available link,
 	setting this option to 0 or to 1 has the exact same effect.
 
+lacp_strict
+
+	Specifies the fallback behavior of a bonding when LACP negotiation
+	fails on all slave links, i.e. when no slave is in the
+	Collecting_Distributing state, while at least `min_links` link still
+	reports carrier up.
+
+	This option is only applicable to 802.3ad mode (mode 4).
+
+	Valid values are:
+
+	off or 0
+		One interface of the bond is selected to be active, in order to
+		facilitate communication with peer devices that do not implement
+		LACP.
+
+	on or 1
+		Interfaces are only permitted to be made active if they have an
+		active LACP partner and have successfully reached
+		Collecting_Distributing state.
+
+	The default value is 0 (off).
+
 mode
 
 	Specifies one of the bonding policies. The default is
drivers/net/bonding/bond_main.c +1 -0
index 82e779f7916b..ec25b83309ec 100644
@@ -6446,6 +6446,7 @@ static int __init bond_check_params(struct bond_params *params)
 	params->ad_user_port_key = ad_user_port_key;
 	params->coupled_control = 1;
 	params->broadcast_neighbor = 0;
+	params->lacp_strict = 0;
 	if (packets_per_slave > 0) {
 		params->reciprocal_packets_per_slave =
 			reciprocal_value(packets_per_slave);
drivers/net/bonding/bond_netlink.c +16 -0
index c7d3e0602c83..08d4d0814f67 100644
@@ -143,6 +143,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
 	[IFLA_BOND_NS_IP6_TARGET]	= { .type = NLA_NESTED },
 	[IFLA_BOND_COUPLED_CONTROL]	= { .type = NLA_U8 },
 	[IFLA_BOND_BROADCAST_NEIGH]	= { .type = NLA_U8 },
+	[IFLA_BOND_LACP_STRICT]		= { .type = NLA_U8 },
 };
 
 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[],
 			return err;
 	}
 
+	if (data[IFLA_BOND_LACP_STRICT]) {
+		int fallback_mode = nla_get_u8(data[IFLA_BOND_LACP_STRICT]);
+
+		bond_opt_initval(&newval, fallback_mode);
+		err = __bond_opt_set(bond, BOND_OPT_LACP_STRICT, &newval,
+				     data[IFLA_BOND_LACP_STRICT], extack);
+		if (err)
+			return err;
+	}
+
 	return 0;
 }
 
@@ -671,6 +682,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
 		nla_total_size(sizeof(struct in6_addr)) * BOND_MAX_NS_TARGETS +
 		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_COUPLED_CONTROL */
 		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_BROADCAST_NEIGH */
+		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_LACP_STRICT */
 		0;
 }
 
@@ -838,6 +850,10 @@ static int bond_fill_info(struct sk_buff *skb,
 		       bond->params.broadcast_neighbor))
 		goto nla_put_failure;
 
+	if (nla_put_u8(skb, IFLA_BOND_LACP_STRICT,
+		       bond->params.lacp_strict))
+		goto nla_put_failure;
+
 	if (BOND_MODE(bond) == BOND_MODE_8023AD) {
 		struct ad_info info;
 
drivers/net/bonding/bond_options.c +26 -0
index 7380cc4ee75a..d358b831df77 100644
@@ -68,6 +68,8 @@ static int bond_option_lacp_active_set(struct bonding *bond,
 				       const struct bond_opt_value *newval);
 static int bond_option_lacp_rate_set(struct bonding *bond,
 				     const struct bond_opt_value *newval);
+static int bond_option_lacp_strict_set(struct bonding *bond,
+				       const struct bond_opt_value *newval);
 static int bond_option_ad_select_set(struct bonding *bond,
 				     const struct bond_opt_value *newval);
 static int bond_option_queue_id_set(struct bonding *bond,
@@ -162,6 +164,12 @@ static const struct bond_opt_value bond_lacp_rate_tbl[] = {
 	{ NULL,   -1,           0},
 };
 
+static const struct bond_opt_value bond_lacp_strict_tbl[] = {
+	{ "off", 0, BOND_VALFLAG_DEFAULT},
+	{ "on",  1, 0},
+	{ NULL, -1, 0 }
+};
+
 static const struct bond_opt_value bond_ad_select_tbl[] = {
 	{ "stable",          BOND_AD_STABLE,    BOND_VALFLAG_DEFAULT},
 	{ "bandwidth",       BOND_AD_BANDWIDTH, 0},
@@ -363,6 +371,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
 		.values = bond_lacp_rate_tbl,
 		.set = bond_option_lacp_rate_set
 	},
+	[BOND_OPT_LACP_STRICT] = {
+		.id = BOND_OPT_LACP_STRICT,
+		.name = "lacp_strict",
+		.desc = "Define the LACP fallback mode when no slaves have negotiated",
+		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
+		.values = bond_lacp_strict_tbl,
+		.set = bond_option_lacp_strict_set
+	},
 	[BOND_OPT_MINLINKS] = {
 		.id = BOND_OPT_MINLINKS,
 		.name = "min_links",
@@ -1684,6 +1700,16 @@ static int bond_option_lacp_rate_set(struct bonding *bond,
 	return 0;
 }
 
+static int bond_option_lacp_strict_set(struct bonding *bond,
+				       const struct bond_opt_value *newval)
+{
+	netdev_dbg(bond->dev, "Setting LACP fallback to %s (%llu)\n",
+		   newval->string, newval->value);
+	bond->params.lacp_strict = newval->value;
+
+	return 0;
+}
+
 static int bond_option_ad_select_set(struct bonding *bond,
 				     const struct bond_opt_value *newval)
 {
include/net/bond_options.h +1 -0
index e6eedf23aea1..52b966e92793 100644
@@ -79,6 +79,7 @@ enum {
 	BOND_OPT_COUPLED_CONTROL,
 	BOND_OPT_BROADCAST_NEIGH,
 	BOND_OPT_ACTOR_PORT_PRIO,
+	BOND_OPT_LACP_STRICT,
 	BOND_OPT_LAST
 };
 
include/net/bonding.h +1 -0
index edd1942dcd73..2c54a36a8477 100644
@@ -129,6 +129,7 @@ struct bond_params {
 	int peer_notif_delay;
 	int lacp_active;
 	int lacp_fast;
+	int lacp_strict;
 	unsigned int min_links;
 	int ad_select;
 	char primary[IFNAMSIZ];
include/uapi/linux/if_link.h +1 -0
index 79ce4bc24cba..9ef5784e78e8 100644
@@ -1584,6 +1584,7 @@ enum {
 	IFLA_BOND_NS_IP6_TARGET,
 	IFLA_BOND_COUPLED_CONTROL,
 	IFLA_BOND_BROADCAST_NEIGH,
+	IFLA_BOND_LACP_STRICT,
 	__IFLA_BOND_MAX,
 };
 
tools/include/uapi/linux/if_link.h +1 -0
index 97a2d4411534..757ce5e9426e 100644
@@ -1527,6 +1527,7 @@ enum {
 	IFLA_BOND_NS_IP6_TARGET,
 	IFLA_BOND_COUPLED_CONTROL,
 	IFLA_BOND_BROADCAST_NEIGH,
+	IFLA_BOND_LACP_STRICT,
 	__IFLA_BOND_MAX,
 };
 
Signature · 1 line
2.39.2
#6 lore raw

PATCH v8 4/6 bonding: 3ad: fix carrier when no usable slaves

In reply to Louis Scalbert

Apply the "lacp_strict" configuration from the previous commit.

"lacp_strict" mode "on" asserts that the bonding master carrier is up only when at least 'min_links' slaves are in the Collecting_Distributing state.

Fixes 655f8919d549 ("bonding: add min links parameter to 802.3ad")
---
 drivers/net/bonding/bond_3ad.c     | 26 +++++++++++++++++++++++---
 drivers/net/bonding/bond_options.c |  1 +
 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_3ad.c +23 -3
index f0aa7d2f2171..98abb2fdd7a6 100644
@@ -745,6 +745,21 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val)
 	}
 }
 
+static int __agg_usable_ports(struct aggregator *agg)
+{
+	struct port *port;
+	int valid = 0;
+
+	for (port = agg->lag_ports; port;
+	     port = port->next_port_in_aggregator) {
+		if (port->actor_oper_port_state & LACP_STATE_COLLECTING &&
+		    port->actor_oper_port_state & LACP_STATE_DISTRIBUTING)
+			valid++;
+	}
+
+	return valid;
+}
+
 static int __agg_active_ports(struct aggregator *agg)
 {
 	struct port *port;
@@ -1179,10 +1194,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)
 		switch (port->sm_mux_state) {
 		case AD_MUX_DETACHED:
 			port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION;
-			ad_disable_collecting_distributing(port,
-							   update_slave_arr);
 			port->actor_oper_port_state &= ~LACP_STATE_COLLECTING;
 			port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING;
+			ad_disable_collecting_distributing(port,
+							   update_slave_arr);
 			port->ntt = true;
 			break;
 		case AD_MUX_WAITING:
@@ -2105,6 +2120,7 @@ static void ad_disable_distributing(struct port *port, bool *update_slave_arr)
 			  port->actor_port_number,
 			  aggregator->aggregator_identifier);
 		__disable_distributing_port(port);
+		bond_3ad_set_carrier(port->slave->bond);
 		/* Slave array needs an update */
 		*update_slave_arr = true;
 	}
@@ -2128,6 +2144,7 @@ static void ad_enable_collecting_distributing(struct port *port,
 			  port->actor_port_number,
 			  aggregator->aggregator_identifier);
 		__enable_port(port);
+		bond_3ad_set_carrier(port->slave->bond);
 		/* Slave array needs update */
 		*update_slave_arr = true;
 		/* Should notify peers if possible */
@@ -2151,6 +2168,7 @@ static void ad_disable_collecting_distributing(struct port *port,
 			  port->actor_port_number,
 			  aggregator->aggregator_identifier);
 		__disable_port(port);
+		bond_3ad_set_carrier(port->slave->bond);
 		/* Slave array needs an update */
 		*update_slave_arr = true;
 	}
@@ -2830,7 +2848,9 @@ int bond_3ad_set_carrier(struct bonding *bond)
 	active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator));
 	if (active) {
 		/* are enough slaves available to consider link up? */
-		if (__agg_active_ports(active) < bond->params.min_links) {
+		if ((bond->params.lacp_strict ? __agg_usable_ports(active)
+					: __agg_active_ports(active)) <
+		    bond->params.min_links) {
 			if (netif_carrier_ok(bond->dev)) {
 				netif_carrier_off(bond->dev);
 				goto out;
drivers/net/bonding/bond_options.c +1 -0
index d358b831df77..94b7b0851f16 100644
@@ -1706,6 +1706,7 @@ static int bond_option_lacp_strict_set(struct bonding *bond,
 	netdev_dbg(bond->dev, "Setting LACP fallback to %s (%llu)\n",
 		   newval->string, newval->value);
 	bond->params.lacp_strict = newval->value;
+	bond_3ad_set_carrier(bond);
 
 	return 0;
 }
Signature · 1 line
2.39.2
maintainer
#7 lore raw

Re: [PATCH net v8 4/6] bonding: 3ad: fix carrier when no usable slaves

Quoted 40 lines · Louis Scalbert

Apply the "lacp_strict" configuration from the previous commit.

"lacp_strict" mode "on" asserts that the bonding master carrier is up only when at least 'min_links' slaves are in the Collecting_Distributing state.

Fixes 655f8919d549 ("bonding: add min links parameter to 802.3ad")

---
drivers/net/bonding/bond_3ad.c | 26 +++++++++++++++++++++++---
drivers/net/bonding/bond_options.c | 1 +

2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_3ad.c +15 -0
index f0aa7d2f2171..98abb2fdd7a6 100644
@@ -745,6 +745,21 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val)
 	}
 }
 
+static int __agg_usable_ports(struct aggregator *agg)
+{
+	struct port *port;
+	int valid = 0;
+
+	for (port = agg->lag_ports; port;
+	     port = port->next_port_in_aggregator) {
+		if (port->actor_oper_port_state & LACP_STATE_COLLECTING &&
+		    port->actor_oper_port_state & LACP_STATE_DISTRIBUTING)
+			valid++;
+	}
+
+	return valid;
+}
+
 static int __agg_active_ports(struct aggregator *agg)
 {
 	struct port *port;

drivers/net/bonding/bond_3ad.c static void ad_mux_machine(struct port *port, bool *update_slave_arr) · line 1200

Quoted 9 lines
drivers/net/bonding/bond_3ad.c +2 -2
@@ -1179,10 +1194,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)
 		switch (port->sm_mux_state) {
 		case AD_MUX_DETACHED:
 			port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION;
-			ad_disable_collecting_distributing(port,
-							   update_slave_arr);
 			port->actor_oper_port_state &= ~LACP_STATE_COLLECTING;
 			port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING;
+			ad_disable_collecting_distributing(port,
+							   update_slave_arr);

Is there a functional reason to move this? I don't see anything
obvious in ad_disable_collecting_distributing() that depends on the actor_oper_port_state. Since you want this to be backported via stable, fewer actual changes reduce the chances of an issue applying the patch to an older version.

	-J
Quoted 53 lines
drivers/net/bonding/bond_3ad.c +6 -1
 			port->ntt = true;
 			break;
 		case AD_MUX_WAITING:
@@ -2105,6 +2120,7 @@ static void ad_disable_distributing(struct port *port, bool *update_slave_arr)
 			  port->actor_port_number,
 			  aggregator->aggregator_identifier);
 		__disable_distributing_port(port);
+		bond_3ad_set_carrier(port->slave->bond);
 		/* Slave array needs an update */
 		*update_slave_arr = true;
 	}
@@ -2128,6 +2144,7 @@ static void ad_enable_collecting_distributing(struct port *port,
 			  port->actor_port_number,
 			  aggregator->aggregator_identifier);
 		__enable_port(port);
+		bond_3ad_set_carrier(port->slave->bond);
 		/* Slave array needs update */
 		*update_slave_arr = true;
 		/* Should notify peers if possible */
@@ -2151,6 +2168,7 @@ static void ad_disable_collecting_distributing(struct port *port,
 			  port->actor_port_number,
 			  aggregator->aggregator_identifier);
 		__disable_port(port);
+		bond_3ad_set_carrier(port->slave->bond);
 		/* Slave array needs an update */
 		*update_slave_arr = true;
 	}
@@ -2830,7 +2848,9 @@ int bond_3ad_set_carrier(struct bonding *bond)
 	active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator));
 	if (active) {
 		/* are enough slaves available to consider link up? */
-		if (__agg_active_ports(active) < bond->params.min_links) {
+		if ((bond->params.lacp_strict ? __agg_usable_ports(active)
+					: __agg_active_ports(active)) <
+		    bond->params.min_links) {
 			if (netif_carrier_ok(bond->dev)) {
 				netif_carrier_off(bond->dev);
 				goto out;
drivers/net/bonding/bond_options.c +1 -0
index d358b831df77..94b7b0851f16 100644
@@ -1706,6 +1706,7 @@ static int bond_option_lacp_strict_set(struct bonding *bond,
 	netdev_dbg(bond->dev, "Setting LACP fallback to %s (%llu)\n",
 		   newval->string, newval->value);
 	bond->params.lacp_strict = newval->value;
+	bond_3ad_set_carrier(bond);
 
 	return 0;
 }
Signature · 1 line
2.39.2

---
-Jay Vosburgh, [email protected]

#8 lore raw

Re: [PATCH net v8 4/6] bonding: 3ad: fix carrier when no usable slaves

Hello Jay,

Quoted 50 lines · Jay Vosburgh
Quoted 47 lines · Louis Scalbert

Apply the "lacp_strict" configuration from the previous commit.

"lacp_strict" mode "on" asserts that the bonding master carrier is up only when at least 'min_links' slaves are in the Collecting_Distributing state.

Fixes 655f8919d549 ("bonding: add min links parameter to 802.3ad")

---
drivers/net/bonding/bond_3ad.c | 26 +++++++++++++++++++++++---
drivers/net/bonding/bond_options.c | 1 +

2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_3ad.c +15 -2
index f0aa7d2f2171..98abb2fdd7a6 100644
@@ -745,6 +745,21 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val)
      }
 }
 
+static int __agg_usable_ports(struct aggregator *agg)
+{
+      struct port *port;
+      int valid = 0;
+
+      for (port = agg->lag_ports; port;
+           port = port->next_port_in_aggregator) {
+              if (port->actor_oper_port_state & LACP_STATE_COLLECTING &&
+                  port->actor_oper_port_state & LACP_STATE_DISTRIBUTING)
+                      valid++;
+      }
+
+      return valid;
+}
+
 static int __agg_active_ports(struct aggregator *agg)
 {
      struct port *port;
@@ -1179,10 +1194,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)
              switch (port->sm_mux_state) {
              case AD_MUX_DETACHED:
                      port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION;
-                      ad_disable_collecting_distributing(port,
-                                                         update_slave_arr);
                      port->actor_oper_port_state &= ~LACP_STATE_COLLECTING;
                      port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING;
Quoted 8 lines

drivers/net/bonding/bond_3ad.c static void ad_mux_machine(struct port *port, bool *update_slave_arr) · line 1200

Quoted 2 lines
drivers/net/bonding/bond_3ad.c +2 -0
+                      ad_disable_collecting_distributing(port,
+                                                         update_slave_arr);

Is there a functional reason to move this? I don't see anything
obvious in ad_disable_collecting_distributing() that depends on the actor_oper_port_state. Since you want this to be backported via stable, fewer actual changes reduce the chances of an issue applying the patch to an older version.

The path is ad_disable_collecting_distributing() -> bond_3ad_set_carrier() -> __agg_usable_ports(). __agg_usable_ports() reads port->actor_oper_port_state

It was found by
https://sashiko.dev/#/message/20260526084048.1696544-5-louis.scalbert%406wind.com

Quoted 52 lines
        -J
Quoted 48 lines
drivers/net/bonding/bond_3ad.c +6 -1
                      port->ntt = true;
                      break;
              case AD_MUX_WAITING:
@@ -2105,6 +2120,7 @@ static void ad_disable_distributing(struct port *port, bool *update_slave_arr)
                        port->actor_port_number,
                        aggregator->aggregator_identifier);
              __disable_distributing_port(port);
+              bond_3ad_set_carrier(port->slave->bond);
              /* Slave array needs an update */
              *update_slave_arr = true;
      }
@@ -2128,6 +2144,7 @@ static void ad_enable_collecting_distributing(struct port *port,
                        port->actor_port_number,
                        aggregator->aggregator_identifier);
              __enable_port(port);
+              bond_3ad_set_carrier(port->slave->bond);
              /* Slave array needs update */
              *update_slave_arr = true;
              /* Should notify peers if possible */
@@ -2151,6 +2168,7 @@ static void ad_disable_collecting_distributing(struct port *port,
                        port->actor_port_number,
                        aggregator->aggregator_identifier);
              __disable_port(port);
+              bond_3ad_set_carrier(port->slave->bond);
              /* Slave array needs an update */
              *update_slave_arr = true;
      }
@@ -2830,7 +2848,9 @@ int bond_3ad_set_carrier(struct bonding *bond)
      active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator));
      if (active) {
              /* are enough slaves available to consider link up? */
-              if (__agg_active_ports(active) < bond->params.min_links) {
+              if ((bond->params.lacp_strict ? __agg_usable_ports(active)
+                                      : __agg_active_ports(active)) <
+                  bond->params.min_links) {
                      if (netif_carrier_ok(bond->dev)) {
                              netif_carrier_off(bond->dev);
                              goto out;
drivers/net/bonding/bond_options.c +1 -0
index d358b831df77..94b7b0851f16 100644
@@ -1706,6 +1706,7 @@ static int bond_option_lacp_strict_set(struct bonding *bond,
      netdev_dbg(bond->dev, "Setting LACP fallback to %s (%llu)\n",
                 newval->string, newval->value);
      bond->params.lacp_strict = newval->value;
+      bond_3ad_set_carrier(bond);
 
Quoted 8 lines
Quoted 5 lines
drivers/net/bonding/bond_options.c +0 -1
      return 0;
 }
--

2.39.2

---
-Jay Vosburgh, [email protected]

best regards,

Louis Scalbert

maintainer
#9 lore raw

Re: [PATCH net v8 4/6] bonding: 3ad: fix carrier when no usable slaves

Quoted 18 lines · Louis Scalbert
Quoted 8 lines · Jay Vosburgh
Quoted 8 lines
drivers/net/bonding/bond_3ad.c +0 -2
@@ -1179,10 +1194,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)
              switch (port->sm_mux_state) {
              case AD_MUX_DETACHED:
                      port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION;
-                      ad_disable_collecting_distributing(port,
-                                                         update_slave_arr);
                      port->actor_oper_port_state &= ~LACP_STATE_COLLECTING;
                      port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING;
Quoted 8 lines

drivers/net/bonding/bond_3ad.c static void ad_mux_machine(struct port *port, bool *update_slave_arr) · line 1200

Quoted 2 lines
drivers/net/bonding/bond_3ad.c +2 -0
+                      ad_disable_collecting_distributing(port,
+                                                         update_slave_arr);

Is there a functional reason to move this? I don't see anything
obvious in ad_disable_collecting_distributing() that depends on the actor_oper_port_state. Since you want this to be backported via stable, fewer actual changes reduce the chances of an issue applying the patch to an older version.

Quoted 6 lines

The path is ad_disable_collecting_distributing() -> bond_3ad_set_carrier() -> __agg_usable_ports(). __agg_usable_ports() reads port->actor_oper_port_state

It was found by
https://sashiko.dev/#/message/20260526084048.1696544-5-louis.scalbert%406wind.com

@Jay: it's not clear to me if you are ok with the series in the current shape, could you please clarify?

Thanks,

Paolo

maintainer Acked-by
#10 lore raw

Re: [PATCH net v8 4/6] bonding: 3ad: fix carrier when no usable slaves

Quoted 23 lines · Paolo Abeni
Quoted 22 lines · Louis Scalbert
Quoted 8 lines · Jay Vosburgh
Quoted 8 lines
drivers/net/bonding/bond_3ad.c +0 -2
@@ -1179,10 +1194,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)
              switch (port->sm_mux_state) {
              case AD_MUX_DETACHED:
                      port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION;
-                      ad_disable_collecting_distributing(port,
-                                                         update_slave_arr);
                      port->actor_oper_port_state &= ~LACP_STATE_COLLECTING;
                      port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING;
Quoted 8 lines

drivers/net/bonding/bond_3ad.c static void ad_mux_machine(struct port *port, bool *update_slave_arr) · line 1200

Quoted 2 lines
drivers/net/bonding/bond_3ad.c +2 -0
+                      ad_disable_collecting_distributing(port,
+                                                         update_slave_arr);

Is there a functional reason to move this? I don't see anything
obvious in ad_disable_collecting_distributing() that depends on the actor_oper_port_state. Since you want this to be backported via stable, fewer actual changes reduce the chances of an issue applying the patch to an older version.

The path is ad_disable_collecting_distributing() -> bond_3ad_set_carrier() -> __agg_usable_ports(). __agg_usable_ports() reads port->actor_oper_port_state

Quoted 5 lines
Quoted 2 lines

It was found by
https://sashiko.dev/#/message/20260526084048.1696544-5-louis.scalbert%406wind.com

@Jay: it's not clear to me if you are ok with the series in the current shape, could you please clarify?

This was the last question I had; everything in this version
seems reasonable.

For the series:

	-J
Quoted 4 lines

Thanks,

Paolo

---
-Jay Vosburgh, [email protected]

maintainer
#11 lore raw

Re: [PATCH net v8 4/6] bonding: 3ad: fix carrier when no usable slaves

Quoted 12 lines · On Tue, 09 Jun 2026 21:01:45 -0700 Jay Vosburgh wrote:
Quoted 11 lines · Louis Scalbert
Quoted 7 lines · Jay Vosburgh

The path is ad_disable_collecting_distributing() -> bond_3ad_set_carrier() -> __agg_usable_ports(). __agg_usable_ports() reads port->actor_oper_port_state

It was found by
https://sashiko.dev/#/message/20260526084048.1696544-5-louis.scalbert%406wind.com

@Jay: it's not clear to me if you are ok with the series in the current shape, could you please clarify?

Quoted 6 lines

This was the last question I had; everything in this version
seems reasonable.

For the series:

Thanks!

To state the obvious it's way too late to be merging this for 7.1

#12 lore raw

PATCH v8 5/6 bonding: 3ad: fix mux port state on oper down

In reply to Louis Scalbert

When the bonding interface has carrier down due to the absence of usable slaves and a slave transitions from down to up, the bonding interface briefly goes carrier up, then down again, and finally up once LACP negotiates collecting and distributing on the port.

When lacp_strict mode is on, the interface should not transition to carrier up until LACP negotiation is complete.

This happens because the actor and partner port states remain in Collecting_Distributing when the port goes down. When the port comes back up, it temporarily remains in this state until LACP renegotiation occurs.

Previously this was mostly cosmetic, but since the bonding carrier state may depend on the LACP negotiation state, it causes the interface to flap.

According to IEEE 802.3ad-2000 and IEEE 802.1ax-2014, Collecting and Distributing should be reset when a port goes down:
- In the Receive state machine, port_enabled == FALSE causes a transition to the PORT_DISABLED state, which is expected to clear Partner_Oper_Port_State.Synchronization.
- In the Mux state machine, Partner_Oper_Port_State.Synchronization == FALSE causes a transition to the ATTACHED state, which disables Collecting and Distributing.

However, Partner_Oper_Port_State.Synchronization is not cleared in the PORT_DISABLED state.

Clear Partner_Oper_Port_State.Synchronization in the Receive PORT_DISABLED state.

Fixes 655f8919d549 ("bonding: add min links parameter to 802.3ad")
---
 drivers/net/bonding/bond_3ad.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/bond_3ad.c +1 -0
index 98abb2fdd7a6..ab7ce9eecbf5 100644
@@ -1337,6 +1337,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 			fallthrough;
 		case AD_RX_PORT_DISABLED:
 			port->sm_vars &= ~AD_PORT_MATCHED;
+			port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION;
 			break;
 		case AD_RX_LACP_DISABLED:
 			port->sm_vars &= ~AD_PORT_SELECTED;
Signature · 1 line
2.39.2
#13 lore raw

PATCH v8 6/6 selftests: bonding: add test for lacp_strict mode

In reply to Louis Scalbert

Add a test for the bonding lacp_strict mode.

---
 .../selftests/drivers/net/bonding/Makefile    |   1 +
 .../drivers/net/bonding/bond_lacp_strict.sh   | 347 ++++++++++++++++++
 2 files changed, 348 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_lacp_strict.sh
tools/testing/selftests/drivers/net/bonding/Makefile +1 -0
index 9af5f84edd37..be130bf585a4 100644
@@ -8,6 +8,7 @@ TEST_PROGS := \
 	bond-lladdr-target.sh \
 	bond_ipsec_offload.sh \
 	bond_lacp_prio.sh \
+	bond_lacp_strict.sh \
 	bond_macvlan_ipvlan.sh \
 	bond_options.sh \
 	bond_passive_lacp.sh \
tools/testing/selftests/drivers/net/bonding/bond_lacp_strict.sh new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
2.39.2
#14 lore raw
In reply to Louis Scalbert
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 3 Jun 2026 17:03:25 +0200 you wrote:

Hi everyone,

This series addresses a blackholing issue and a subsequent link-flapping issue in the 802.3ad bonding driver when dealing with inactive slaves and the min_links parameter.

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.

[...]

Here is the summary with links:
- [net,v8,1/6] tools: missed broadcast_neigh if_link uapi header

    https://git.kernel.org/netdev/net-next/c/0134432215f0
  - [net,v8,2/6] netlink: specs: rt-link: missed broadcast-neigh
    https://git.kernel.org/netdev/net-next/c/363037983cc5
  - [net,v8,3/6] bonding: 3ad: add lacp_strict configuration knob
    https://git.kernel.org/netdev/net-next/c/32b0b8953343
  - [net,v8,4/6] bonding: 3ad: fix carrier when no usable slaves
    https://git.kernel.org/netdev/net-next/c/0bd695db23c6
  - [net,v8,5/6] bonding: 3ad: fix mux port state on oper down
    https://git.kernel.org/netdev/net-next/c/807afc7544b8
  - [net,v8,6/6] selftests: bonding: add test for lacp_strict mode
    https://git.kernel.org/netdev/net-next/c/f17e4fcc2b68

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html