🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Jay Vosburgh Wed, 18 Nov 2026 20:00
Re: [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes
#18736
Author: Jay Vosburgh
Date: Wed, 18 Nov 2026 20:00
166 lines
18973 bytes
Ido Schimmel <idosch@nvidia.com> wrote:

>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.

	How do we know this is harmless?  Isn't this a change of
behavior that's visible to user space?

	-J

> 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
>

---
	-Jay Vosburgh, jv@jvosburgh.net
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads