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 Signed-off-by: Ido Schimmel --- 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