Netdev List
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, jv@jvosburgh.net, 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,
	Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled
Date: Wed, 18 Nov 2026 10:34:41 +0200	[thread overview]
Message-ID: <20261118083442.1061289-6-idosch@nvidia.com> (raw)
In-Reply-To: <20261118083442.1061289-1-idosch@nvidia.com>

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


  parent reply	other threads:[~2026-11-18  8:36 UTC|newest]

Thread overview: 7+ 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  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 ` Ido Schimmel [this message]
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=20261118083442.1061289-6-idosch@nvidia.com \
    --to=idosch@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=jv@jvosburgh.net \
    --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