* [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload
@ 2026-11-18 8:34 Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 1/6] net: Add Rx enabled state to LAG lower state information Ido Schimmel
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
When coupled control is disabled (i.e., independent control is enabled),
an 802.3ad port can be in COLLECTING state where it is enabled for
collection, but not for distribution. This is useful in deployments that
want to avoid packet loss caused by a port starting to distribute before
its partner starts collecting.
Drivers that offload LAG are not aware of this Rx-only state since the
LAG lower state information only indicates whether the port is enabled
for transmission and the bond does not notify about Rx state changes.
Instead, these drivers enable or disable both collection and
distribution on the port according to its Tx state. As a result, packets
received by a port in COLLECTING state are dropped by the hardware.
In addition, a port that enters COLLECTING state advertises the
Collecting bit in its LACPDUs before offloading drivers are notified
about the Rx state change. The partner can therefore start distributing
packets to the port before collection is enabled, which defeats the
purpose of independent control.
Patch #1 adds an Rx enabled state to the LAG lower state information and
sets it according to the existing Tx enabled state.
Patch #2 sets this state in the bond driver according to the port's Rx
state and notifies about Rx state changes. The team driver keeps setting
it according to the Tx state.
Patch #3 changes mlxsw to enable collection independently of
distribution. Other drivers keep using the Tx enabled state, so their
behavior does not change.
Patch #4 adds a selftest for the Rx notifications (i.e., entering /
leaving COLLECTING state).
Patch #5 masks the Collecting bit in transmitted LACPDUs until the
notification about the Rx state change has been delivered.
Patch #6 adds a selftest for the previous patch.
Ido Schimmel (6):
net: Add Rx enabled state to LAG lower state information
bonding: 3ad: Notify Rx state changes
mlxsw: Enable LAG collector independently of distributor
selftests: bonding: Test notifications in COLLECTING state
bonding: 3ad: Advertise Collecting only after collection is enabled
selftests: bonding: Test that Collecting is advertised after
notification
drivers/net/bonding/bond_3ad.c | 24 ++++-
drivers/net/bonding/bond_main.c | 4 +
.../net/ethernet/mellanox/mlxsw/spectrum.c | 15 +++
drivers/net/net_failover.c | 1 +
drivers/net/team/team_core.c | 1 +
include/linux/netdevice.h | 3 +-
include/net/bonding.h | 25 ++++-
.../bonding/bond_lacp_independent_control.sh | 94 ++++++++++++++++++-
8 files changed, 159 insertions(+), 8 deletions(-)
--
2.56.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 1/6] net: Add Rx enabled state to LAG lower state information
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
@ 2026-11-18 8:34 ` Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes Ido Schimmel
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
The LAG lower state information that is passed to drivers via the
NETDEV_CHANGELOWERSTATE notifier only indicates whether the lower device
is enabled for transmission ('tx_enabled'). Drivers such as mlxsw use
it to enable or disable both collection and distribution on the port.
This is not enough for an 802.3ad bond with coupled control disabled,
where a port can be enabled for collection, but not for distribution.
Add an 'rx_enabled' field that indicates whether the lower device is
enabled for reception. For now, set it to the value of 'tx_enabled' in
all the LAG drivers. A subsequent patch will set it differently in the
bond driver.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/bonding/bond_main.c | 1 +
drivers/net/net_failover.c | 1 +
drivers/net/team/team_core.c | 1 +
include/linux/netdevice.h | 3 ++-
4 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 167503d1fd15..7eb3ff82ec96 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1831,6 +1831,7 @@ void bond_lower_state_changed(struct slave *slave)
info.link_up = slave->link == BOND_LINK_UP ||
slave->link == BOND_LINK_FAIL;
info.tx_enabled = bond_is_active_slave(slave);
+ info.rx_enabled = info.tx_enabled;
netdev_lower_state_changed(slave->dev, &info);
}
diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 1b5213e87070..c4d39f8b8802 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -451,6 +451,7 @@ static void net_failover_lower_state_changed(struct net_device *slave_dev,
else
info.tx_enabled = true;
}
+ info.rx_enabled = info.tx_enabled;
netdev_lower_state_changed(slave_dev, &info);
}
diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index cfb833c307c1..def94cbc8384 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -88,6 +88,7 @@ static void team_lower_state_changed(struct team_port *port)
info.link_up = port->linkup;
info.tx_enabled = team_port_tx_enabled(port);
+ info.rx_enabled = info.tx_enabled;
netdev_lower_state_changed(port->dev, &info);
}
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0325c6f2a7d1..694b6d29f680 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3239,7 +3239,8 @@ struct netdev_lag_upper_info {
struct netdev_lag_lower_state_info {
u8 link_up : 1,
- tx_enabled : 1;
+ tx_enabled : 1,
+ rx_enabled : 1;
};
#include <linux/notifier.h>
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 1/6] net: Add Rx enabled state to LAG lower state information Ido Schimmel
@ 2026-11-18 8:34 ` Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor Ido Schimmel
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
When coupled control is disabled, a port in COLLECTING state is enabled
for collection, but not for distribution. However, drivers that offload
LAG are not notified when a port enters or leaves this state since the
bond only notifies them when the port's 'backup' flag changes.
Fix by setting 'rx_enabled' in the LAG lower state information according
to the slave's 'rx_disabled' flag in 802.3ad mode and by notifying when
this flag changes. Track pending notifications using a separate bit
since 'should_notify' is toggled when the 'backup' flag changes.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
Known issues that this patch does not address:
1. The new 'should_notify_rx' bit shares a bitfield with other slave
flags. The 802.3ad state machine writes them under the mode lock, while
a few other paths (e.g., the 'all_slaves_active' handler) write them
under RTNL only. This is not new.
2. When a port is disabled with BOND_SLAVE_NOTIFY_NOW, two notifications
are sent: one after the Tx state change and one after the Rx state
change. This is harmless.
drivers/net/bonding/bond_3ad.c | 2 +-
drivers/net/bonding/bond_main.c | 5 ++++-
include/net/bonding.h | 25 +++++++++++++++++++++----
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d91533b80996..d2a55f4d8979 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2608,7 +2608,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
re_arm:
bond_for_each_slave_rcu(bond, slave, iter) {
- if (slave->should_notify) {
+ if (slave->should_notify || slave->should_notify_rx) {
should_notify_rtnl = BOND_SLAVE_NOTIFY_NOW;
break;
}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7eb3ff82ec96..4ba1f5c33251 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1831,7 +1831,10 @@ void bond_lower_state_changed(struct slave *slave)
info.link_up = slave->link == BOND_LINK_UP ||
slave->link == BOND_LINK_FAIL;
info.tx_enabled = bond_is_active_slave(slave);
- info.rx_enabled = info.tx_enabled;
+ if (BOND_MODE(slave->bond) == BOND_MODE_8023AD)
+ info.rx_enabled = !bond_is_slave_rx_disabled(slave);
+ else
+ info.rx_enabled = info.tx_enabled;
netdev_lower_state_changed(slave->dev, &info);
}
diff --git a/include/net/bonding.h b/include/net/bonding.h
index cb89aff437f4..5980df71a358 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -170,6 +170,7 @@ struct slave {
inactive:1, /* indicates inactive slave */
rx_disabled:1, /* indicates whether slave's Rx is disabled */
should_notify:1, /* indicates whether the state changed */
+ should_notify_rx:1, /* indicates whether the Rx state changed */
should_notify_link:1; /* indicates whether the link changed */
u8 duplex;
u32 original_mtu;
@@ -399,6 +400,21 @@ static inline void bond_set_slave_state(struct slave *slave,
}
}
+static inline void bond_set_slave_rx_disabled(struct slave *slave,
+ bool rx_disabled, bool notify)
+{
+ if (slave->rx_disabled == rx_disabled)
+ return;
+
+ slave->rx_disabled = rx_disabled;
+ if (notify) {
+ bond_lower_state_changed(slave);
+ slave->should_notify_rx = 0;
+ } else {
+ slave->should_notify_rx = 1;
+ }
+}
+
static inline void bond_slave_state_change(struct bonding *bond)
{
struct list_head *iter;
@@ -418,9 +434,10 @@ static inline void bond_slave_state_notify(struct bonding *bond)
struct slave *tmp;
bond_for_each_slave(bond, tmp, iter) {
- if (tmp->should_notify) {
+ if (tmp->should_notify || tmp->should_notify_rx) {
bond_lower_state_changed(tmp);
tmp->should_notify = 0;
+ tmp->should_notify_rx = 0;
}
}
}
@@ -573,7 +590,7 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave,
if (!slave->bond->params.all_slaves_active)
slave->inactive = 1;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD)
- slave->rx_disabled = 1;
+ bond_set_slave_rx_disabled(slave, true, notify);
}
static inline void bond_set_slave_tx_disabled_flags(struct slave *slave,
@@ -588,14 +605,14 @@ static inline void bond_set_slave_active_flags(struct slave *slave,
bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify);
slave->inactive = 0;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD)
- slave->rx_disabled = 0;
+ bond_set_slave_rx_disabled(slave, false, notify);
}
static inline void bond_set_slave_rx_enabled_flags(struct slave *slave,
bool notify)
{
slave->inactive = 0;
- slave->rx_disabled = 0;
+ bond_set_slave_rx_disabled(slave, false, notify);
}
static inline bool bond_is_slave_inactive(struct slave *slave)
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 1/6] net: Add Rx enabled state to LAG lower state information Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes Ido Schimmel
@ 2026-11-18 8:34 ` Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 4/6] selftests: bonding: Test notifications in COLLECTING state Ido Schimmel
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
The driver enables or disables both the collector and the distributor of
a LAG port according to 'tx_enabled'. As a result, when coupled control
is disabled in an 802.3ad bond, a port in COLLECTING state does not
receive packets.
Fix by enabling the collector and removing the port from the distributor
when 'rx_enabled' is set, but 'tx_enabled' is not.
The port is not necessarily in the distributor list when it is removed
from it (e.g., when it moves from ATTACHED to COLLECTING state). This is
fine since the device allows removing a port that was already removed
and returns success.
Do not add the port back to the distributor list if enabling the
collector fails. The port should not be in the list when 'tx_enabled' is
not set and it might not have been in the list to begin with.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
The error paths of mlxsw_sp_port_lag_col_dist_enable() and
mlxsw_sp_port_lag_col_dist_disable() do not take the new collection-only
state into account and might not restore the previous state. I do not
think it is worth handling. These errors are only logged and not
propagated to the LAG driver, so the hardware and the LAG driver are out
of sync regardless of what the rollback does. In addition, these
register writes are not expected to fail and I have never seen them
fail.
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 815e8d8e3185..5a6dc033084d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4515,11 +4515,26 @@ mlxsw_sp_port_lag_col_dist_disable(struct mlxsw_sp_port *mlxsw_sp_port)
return err;
}
+static int mlxsw_sp_port_lag_col_enable(struct mlxsw_sp_port *mlxsw_sp_port)
+{
+ int err;
+
+ err = mlxsw_sp_lag_dist_port_remove(mlxsw_sp_port,
+ mlxsw_sp_port->lag_id);
+ if (err)
+ return err;
+
+ return mlxsw_sp_lag_col_port_enable(mlxsw_sp_port,
+ mlxsw_sp_port->lag_id);
+}
+
static int mlxsw_sp_port_lag_changed(struct mlxsw_sp_port *mlxsw_sp_port,
struct netdev_lag_lower_state_info *info)
{
if (info->tx_enabled)
return mlxsw_sp_port_lag_col_dist_enable(mlxsw_sp_port);
+ else if (info->rx_enabled)
+ return mlxsw_sp_port_lag_col_enable(mlxsw_sp_port);
else
return mlxsw_sp_port_lag_col_dist_disable(mlxsw_sp_port);
}
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 4/6] selftests: bonding: Test notifications in COLLECTING state
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
` (2 preceding siblings ...)
2026-11-18 8:34 ` [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor Ido Schimmel
@ 2026-11-18 8:34 ` Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification Ido Schimmel
5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
Test that with coupled control disabled, a notification is emitted when
a port enters or leaves COLLECTING state.
Output without "bonding: 3ad: Notify Rx state changes":
# ./bond_lacp_independent_control.sh
TEST: Receive in COLLECTING state [ OK ]
TEST: Notifications in COLLECTING state [FAIL]
No notification upon entering COLLECTING state
TEST: Ping in DISTRIBUTING state [ OK ]
Output with the fix:
# ./bond_lacp_independent_control.sh
TEST: Receive in COLLECTING state [ OK ]
TEST: Notifications in COLLECTING state [ OK ]
TEST: Ping in DISTRIBUTING state [ OK ]
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
.../bonding/bond_lacp_independent_control.sh | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh b/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
index c29712e01e49..a2b83b581e40 100755
--- a/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
+++ b/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
@@ -15,6 +15,7 @@
# shellcheck disable=SC2034,SC2329
ALL_TESTS="
collecting
+ collecting_notify
distributing
"
NUM_NETIFS=2
@@ -121,6 +122,46 @@ collecting()
log_test "Receive in COLLECTING state"
}
+collecting_notify()
+{
+ local tmp_file
+
+ RET=0
+
+ partner_state_clear 0x18
+ defer tc filter del dev "$h1" ingress pref 1 handle 101 flower
+ lacp_state_wait "$h1" 0x0f
+ check_err $? "Port did not reach ATTACHED state"
+
+ tmp_file=$(mktemp)
+ defer rm "$tmp_file"
+ ip -d monitor link dev "$h1" >> "$tmp_file" &
+ defer kill_process $!
+ sleep 1
+
+ partner_state_clear 0x10
+ lacp_state_wait "$h1" 0x1f
+ check_err $? "Port did not reach COLLECTING state"
+
+ slowwait "$WAIT_TIMEOUT" grep -qw \
+ "ad_actor_oper_port_state $((0x1f))" "$tmp_file"
+ check_err $? "No notification upon entering COLLECTING state"
+
+ # Discard previous notifications so that only a notification upon
+ # leaving COLLECTING state can match below. The monitor appends to
+ # the file, so truncating it is safe.
+ : > "$tmp_file"
+ partner_state_clear 0x18
+ lacp_state_wait "$h1" 0x0f
+ check_err $? "Port did not reach ATTACHED state"
+
+ slowwait "$WAIT_TIMEOUT" grep -qw \
+ "ad_actor_oper_port_state $((0x0f))" "$tmp_file"
+ check_err $? "No notification upon leaving COLLECTING state"
+
+ log_test "Notifications in COLLECTING state"
+}
+
distributing()
{
RET=0
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
` (3 preceding siblings ...)
2026-11-18 8:34 ` [PATCH net-next 4/6] selftests: bonding: Test notifications in COLLECTING state Ido Schimmel
@ 2026-11-18 8:34 ` Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification Ido Schimmel
5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
When coupled control is disabled, a port that enters COLLECTING state
advertises the Collecting bit in the LACPDU that is transmitted in the
same state machine run. However, drivers that offload LAG only enable
collection on the port when they are notified about its Rx state change,
which happens at the end of the run or later if RTNL could not be
acquired. The partner can therefore start distributing packets to the
port before collection is enabled in hardware, resulting in packet loss.
This contradicts IEEE 802.1AX-2020 6.4.13: "In the COLLECTING state,
collection of frames from the Aggregation Port is enabled, then
Actor_Oper_Port_State.Collecting is set to TRUE".
Solve this by masking the Collecting bit in transmitted LACPDUs as long
as the notification is pending and by transmitting a new LACPDU once it
was delivered.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/bonding/bond_3ad.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d2a55f4d8979..61f6de803b66 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -250,6 +250,19 @@ static int __port_is_collecting_distributing(struct port *port)
return bond_is_active_slave(port->slave);
}
+/**
+ * __port_rx_notify_pending - check if the port's Rx state change was not
+ * notified yet when coupled control is disabled
+ * @port: the port we're looking at
+ *
+ * Return: true if the notification is pending, false otherwise.
+ */
+static bool __port_rx_notify_pending(struct port *port)
+{
+ return !port->slave->bond->params.coupled_control &&
+ port->slave->should_notify_rx;
+}
+
/**
* __get_agg_selection_mode - get the aggregator selection mode
* @port: the port we're looking at
@@ -903,6 +916,9 @@ static inline void __update_lacpdu_from_port(struct port *port)
lacpdu->actor_port_priority = htons(port->actor_port_priority);
lacpdu->actor_port = htons(port->actor_port_number);
lacpdu->actor_state = port->actor_oper_port_state;
+ /* Collection is only enabled once the Rx state change is notified */
+ if (__port_rx_notify_pending(port))
+ lacpdu->actor_state &= ~LACP_STATE_COLLECTING;
slave_dbg(port->slave->bond->dev, port->slave->dev,
"update lacpdu: actor port state %x\n",
port->actor_oper_port_state);
@@ -1440,6 +1456,12 @@ static void ad_churn_machine(struct port *port)
*/
static void ad_tx_machine(struct port *port)
{
+ /* Advertise Collecting if it was masked in the last LACPDU */
+ if ((port->actor_oper_port_state & LACP_STATE_COLLECTING) &&
+ !(port->lacpdu.actor_state & LACP_STATE_COLLECTING) &&
+ !__port_rx_notify_pending(port))
+ port->ntt = true;
+
/* check if tx timer expired, to verify that we do not send more than
* 3 packets per second
*/
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
` (4 preceding siblings ...)
2026-11-18 8:34 ` [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled Ido Schimmel
@ 2026-11-18 8:34 ` Ido Schimmel
5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-18 8:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, jv, andrew+netdev, petrm,
sridhar.samudrala, jiri, horms, shuah, linux-kselftest, razor,
Ido Schimmel
Test that with coupled control disabled, a port only advertises the
Collecting bit after a notification about its Rx state change was
emitted.
Use a slow LACP rate on the partner so that the port only transmits
periodic LACPDUs every 30 seconds and is therefore not rate limited when
entering COLLECTING state.
Output without "bonding: 3ad: Advertise Collecting only after collection
is enabled":
# ./bond_lacp_independent_control.sh
TEST: Receive in COLLECTING state [ OK ]
TEST: Notifications in COLLECTING state [ OK ]
TEST: Collecting advertised after notification [FAIL]
Collecting bit advertised before notification
TEST: Ping in DISTRIBUTING state [ OK ]
Output with the fix:
# ./bond_lacp_independent_control.sh
TEST: Receive in COLLECTING state [ OK ]
TEST: Notifications in COLLECTING state [ OK ]
TEST: Collecting advertised after notification [ OK ]
TEST: Ping in DISTRIBUTING state [ OK ]
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
The test compares a user space timestamp (ip monitor) with a kernel
timestamp (tcpdump). This cannot hide a bug since a delay in ip can only
make the notification appear later. A false failure requires ip to stall
for longer than the gap between the notification and the LACPDU, which
is at least one state machine tick (100 ms). Did not observe such a
failure with normal or debug kernels.
.../bonding/bond_lacp_independent_control.sh | 53 ++++++++++++++++++-
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh b/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
index a2b83b581e40..b86f39f31d0c 100755
--- a/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
+++ b/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
@@ -4,7 +4,7 @@
# +-------------------------+ +-------------------------+
# | H1 (vrf) | | H2 (vrf) |
# | + bond1 (802.3ad) | | + bond2 (802.3ad) |
-# | | coupled_control off | | | |
+# | | coupled_control off | | | lacp_rate slow |
# | | 192.0.2.1/28 | | | 192.0.2.2/28 |
# | | | | | |
# | + $h1 | | + $h2 |
@@ -16,6 +16,7 @@
ALL_TESTS="
collecting
collecting_notify
+ collecting_advertise
distributing
"
NUM_NETIFS=2
@@ -24,6 +25,8 @@ lib_dir=$(dirname "$0")
# shellcheck disable=SC1091
source "$lib_dir"/../../../net/forwarding/lib.sh
+require_command tcpdump
+
lacp_state_get()
{
local dev=$1; shift
@@ -75,7 +78,9 @@ h1_create()
h2_create()
{
- adf_ip_link_add bond2 type bond mode 802.3ad lacp_rate fast
+ # Slow rate makes $h1 transmit periodic LACPDUs every 30 seconds, so
+ # that it is not rate limited when entering COLLECTING state.
+ adf_ip_link_add bond2 type bond mode 802.3ad lacp_rate slow
adf_ip_link_set_master "$h2" bond2
adf_simple_if_init bond2 192.0.2.2/28
}
@@ -162,6 +167,50 @@ collecting_notify()
log_test "Notifications in COLLECTING state"
}
+collecting_advertise()
+{
+ local lacpdu_ts notify_ts tmp_dir
+
+ RET=0
+
+ partner_state_clear 0x18
+ defer tc filter del dev "$h1" ingress pref 1 handle 101 flower
+ lacp_state_wait "$h1" 0x0f
+ check_err $? "Port did not reach ATTACHED state"
+
+ tmp_dir=$(mktemp -d)
+ defer rm -rf "$tmp_dir"
+ ip -ts -o -d monitor link dev "$h1" > "$tmp_dir"/notify &
+ defer kill_process $!
+ # Capture transmitted LACPDUs with the Collecting (0x10) bit set in
+ # the actor state.
+ tcpdump -tt -n -l -p -Q out -i "$h1" \
+ "ether proto 0x8809 and ether[32] & 0x10 != 0" \
+ > "$tmp_dir"/lacpdu 2> /dev/null &
+ defer kill_process $!
+ sleep 1
+
+ partner_state_clear 0x10
+ lacp_state_wait "$h1" 0x1f
+ check_err $? "Port did not reach COLLECTING state"
+
+ slowwait "$WAIT_TIMEOUT" grep -qw \
+ "ad_actor_oper_port_state $((0x1f))" "$tmp_dir"/notify
+ check_err $? "No notification upon entering COLLECTING state"
+
+ slowwait "$WAIT_TIMEOUT" grep -q . "$tmp_dir"/lacpdu
+ check_err $? "Collecting bit not advertised"
+
+ notify_ts=$(grep -m1 -w "ad_actor_oper_port_state $((0x1f))" \
+ "$tmp_dir"/notify | sed 's/^\[\([^]]*\)\].*/\1/')
+ notify_ts=$(date -d "$notify_ts" +%s%6N)
+ lacpdu_ts=$(head -n1 "$tmp_dir"/lacpdu | cut -d' ' -f1 | tr -d .)
+ ((lacpdu_ts > notify_ts))
+ check_err $? "Collecting bit advertised before notification"
+
+ log_test "Collecting advertised after notification"
+}
+
distributing()
{
RET=0
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-18 8:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 1/6] net: Add Rx enabled state to LAG lower state information Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 4/6] selftests: bonding: Test notifications in COLLECTING state Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification Ido Schimmel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox