From: Jay Vosburgh <jv@jvosburgh.net>
To: Ido Schimmel <idosch@nvidia.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, edumazet@kernel.org, andrew+netdev@lunn.ch,
petrm@nvidia.com, sridhar.samudrala@intel.com, jiri@resnulli.us,
horms@kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org, razor@blackwall.org
Subject: Re: [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes
Date: Wed, 18 Nov 2026 12:00:15 -0800 [thread overview]
Message-ID: <528757.1795032015@famine> (raw)
In-Reply-To: <20261118083442.1061289-3-idosch@nvidia.com>
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
next prev parent reply other threads:[~2026-11-18 20:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 20:00 ` Jay Vosburgh [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=528757.1795032015@famine \
--to=jv@jvosburgh.net \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=razor@blackwall.org \
--cc=shuah@kernel.org \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox