bonding: 3ad: Support independent control with LAG offload
Subsystems (7)
Ido Schimmel
maintainercover bonding: 3ad: Support independent control with LAG offload
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(-)
Signature · 1 line
2.56.0
Ido Schimmel
maintainerPATCH 1/6 net: Add Rx enabled state to LAG lower state information
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.
--- 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(-)
drivers/net/bonding/bond_main.c +1 -0
@@ -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); }
drivers/net/net_failover.c +1 -0
@@ -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); }
drivers/net/team/team_core.c +1 -0
@@ -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); }
include/linux/netdevice.h +2 -1
@@ -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>
Signature · 1 line
2.56.0
Ido Schimmel
maintainerPATCH 2/6 bonding: 3ad: Notify Rx state changes
In reply to Ido SchimmelWhen 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.
---
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(-)
drivers/net/bonding/bond_3ad.c +1 -1
@@ -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 ; }
drivers/net/bonding/bond_main.c +4 -1
@@ -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); }
include/net/bonding.h +21 -4
@@ -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)
Signature · 1 line
2.56.0
Jay Vosburgh
maintainerRe: [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes
Quoted 17 lines · 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 <[email protected]>Signed-off-by Ido Schimmel <[email protected]>---
Notes:
Known issues that this patch does not address:
Quoted 8 lines
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
Quoted 109 lines
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(-)drivers/net/bonding/bond_3ad.c +0
-0@@ -2608,7 +2608,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
re_arm:bond_for_each_slave_rcu(bond, slave, iter) {drivers/net/bonding/bond_3ad.c +1
-1-if (slave->should_notify) { +if (slave->should_notify || slave->should_notify_rx) {should_notify_rtnl = BOND_SLAVE_NOTIFY_NOW; break; }drivers/net/bonding/bond_main.c +4
-1@@ -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); }include/net/bonding.h +21
-4@@ -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)Signature · 1 line
2.56.0
---
-Jay Vosburgh, [email protected]
Ido Schimmel
maintainerRe: [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes
Quoted 24 lines · Jay Vosburgh
Quoted 22 lines · 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 <[email protected]>Signed-off-by Ido Schimmel <[email protected]>---
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.
Quoted 6 lines
Quoted 3 lines
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?
The change in behavior is one additional RTM_NEWLINK notification that is identical to the previous one in a path that already generates multiple such notifications. I don't see how it can be harmful.
Ido Schimmel
maintainerPATCH 3/6 mlxsw: Enable LAG collector independently of distributor
In reply to Ido SchimmelThe 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.
---
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(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +15 -0
@@ -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); }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new collection-only state (SLCOR collector on, port not in the SLDR distributor list), reached through…
--
mlxsw: Enable LAG collector independently of distributor
This patch adds a collection-only state for LAG ports. When rx_enabled is set and tx_enabled is not, mlxsw_sp_port_lag_changed() now enables the SLCOR collector and removes the port from the SLDR distributor list. Without this, a port in COLLECTING state in an 802.3ad bond with coupled control disabled did not receive packets.
Quoted 18 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +10
-0@@ -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,
drivers/net/ethernet/mellanox/mlxsw/spectrum.c mlxsw_sp_port_lag_col_dist_disable(struct mlxsw_sp_port *mlxsw_sp_port) · line 4537
Quoted 10 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +5
-0+ 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);
[Severity: Low]
With the new collection-only state (collector on, port not in the distributor list), do the error paths in the two existing helpers still do the right thing? Both cases need a register write to fail.
A move from COLLECTING to COLLECTING_DISTRIBUTING calls mlxsw_sp_port_lag_col_dist_enable(). If the SLDR add fails, the error path turns off a collector that was already correctly enabled:
mlxsw_sp_port_lag_col_dist_enable() {
...
err_dist_port_add:
mlxsw_sp_lag_col_port_disable(mlxsw_sp_port, mlxsw_sp_port->lag_id);
return err;
}Would this drop ingress on a link that both partners negotiated as COLLECTING?
A move from COLLECTING to ATTACHED or DETACHED calls mlxsw_sp_port_lag_col_dist_disable(). The SLDR remove succeeds even though the port was never in the list. If the SLCOR disable then fails, the error path adds the port to the distributor list:
mlxsw_sp_port_lag_col_dist_disable() {
...
err_col_port_disable:
mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id);
return err;
}Could the device then hash LAG egress onto a port that LACP never moved to DISTRIBUTING, while bonding has tx disabled for it? That state matches neither the old LAG state nor the new one.
mlxsw_sp_netdevice_port_lower_event() only logs "Failed to reflect link aggregation lower state change", so the hardware stays in that state until the next lower state event.
The patch notes say the hardware and the LAG driver are out of sync "regardless of what the rollback does". In the second case, though, the rollback turns on tx distribution that neither state wants. The notes are also not in the commit message or in a code comment.
Could the re-add be skipped when the port was in collection-only state, or could this limitation be documented in the commit message?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118083442.1061289-1-idosch%40nvidia.com
Ido Schimmel
maintainerRe: [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor
tl;dr - I believe the patch is fine as-is.
Quoted 87 lines · On Thu, Nov 19, 2026 at 09:19:41AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new collection-only state (SLCOR collector on, port not in the SLDR distributor list), reached through…
--
mlxsw: Enable LAG collector independently of distributor
This patch adds a collection-only state for LAG ports. When
rx_enabledis set andtx_enabledis not,mlxsw_sp_port_lag_changed()now enables the SLCOR collector and removes the port from the SLDR distributor list. Without this, a port in COLLECTING state in an 802.3ad bond with coupled control disabled did not receive packets.Quoted 18 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +10
-0@@ -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,drivers/net/ethernet/mellanox/mlxsw/spectrum.c mlxsw_sp_port_lag_col_dist_disable(struct mlxsw_sp_port *mlxsw_sp_port) · line 4537
Quoted 10 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +5
-0+ 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);[Severity: Low]
With the new collection-only state (collector on, port not in the distributor list), do the error paths in the two existing helpers still do the right thing? Both cases need a register write to fail.A move from COLLECTING to
COLLECTING_DISTRIBUTINGcallsmlxsw_sp_port_lag_col_dist_enable(). If the SLDR add fails, the error path turns off a collector that was already correctly enabled:mlxsw_sp_port_lag_col_dist_enable() { ... err_dist_port_add: mlxsw_sp_lag_col_port_disable(mlxsw_sp_port, mlxsw_sp_port->lag_id); return err; }Would this drop ingress on a link that both partners negotiated as COLLECTING?
A move from COLLECTING to ATTACHED or DETACHED calls
mlxsw_sp_port_lag_col_dist_disable(). The SLDR remove succeeds even though the port was never in the list. If the SLCOR disable then fails, the error path adds the port to the distributor list:mlxsw_sp_port_lag_col_dist_disable() { ... err_col_port_disable: mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); return err; }Could the device then hash LAG egress onto a port that LACP never moved to DISTRIBUTING, while bonding has tx disabled for it? That state matches neither the old LAG state nor the new one.
mlxsw_sp_netdevice_port_lower_event()only logs "Failed to reflect link aggregation lower state change", so the hardware stays in that state until the next lower state event.
Quoted 7 lines
The patch notes say the hardware and the LAG driver are out of sync "regardless of what the rollback does". In the second case, though, the rollback turns on tx distribution that neither state wants. The notes are also not in the commit message or in a code comment.
Could the re-add be skipped when the port was in collection-only state, or could this limitation be documented in the commit message?
These registers don't allocate new resources, they don't have a reason to fail and I've never seen them fail. If they failed, then the system is in a very bad state where the state of a LAG is largely irrelevant.
I put this info under the '---' because I am trying to keep commit messages readable for humans and not to overload them with irrelevant info whose sole purpose is pleasing an LLM.
Ido Schimmel
maintainerPATCH 4/6 selftests: bonding: Test notifications in COLLECTING state
In reply to Ido SchimmelTest 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 ]
--- .../bonding/bond_lacp_independent_control.sh | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +41 -0
@@ -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
Signature · 1 line
2.56.0
Ido Schimmel
maintainerPATCH 5/6 bonding: 3ad: Advertise Collecting only after collection is enabled
In reply to Ido SchimmelWhen 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.
--- drivers/net/bonding/bond_3ad.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/net/bonding/bond_3ad.c +22 -0
@@ -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 */
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In __update_lacpdu_from_port() (drivers/net/bonding/bond_3ad.c), the patch clears LACP_STATE_COLLECTING in lacpdu->actor_state when…
- [Low] While the Rx notification is pending, procfs ("details actor lacp
pdu: port state"), sysfs ad_actor_oper_port_state and netlink…
- [Low] __update_lacpdu_from_port() masks only LACP_STATE_COLLECTING while the Rx notification is pending.
--
bonding: 3ad: Advertise Collecting only after collection is enabled
When coupled control is disabled, this commit clears the Collecting bit in transmitted LACPDUs while the port's Rx state change notification is still pending. Once the notification is delivered, ad_tx_machine() sets ntt so that a new LACPDU advertising Collecting goes out.
Quoted 4 lines
drivers/net/bonding/bond_3ad.c +0
-0
[ ... ]
drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_port(struct port *port) · line 921
Quoted 7 lines
drivers/net/bonding/bond_3ad.c +3
-0@@ -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 ;
[Severity: Low]
This masks only Collecting. Can the transmitted actor_state have Distributing set while Collecting is cleared?
Suppose rtnl_trylock() fails in bond_3ad_state_machine_handler() at the end of the run that entered AD_MUX_COLLECTING. Then should_notify_rx stays set. On the next tick, ad_mux_machine() can move to AD_MUX_DISTRIBUTING based only on the partner's state:
case AD_MUX_COLLECTING:
if (!__port_move_to_attached_state(port)) {
if ((port->sm_vars & AD_PORT_SELECTED) &&
(port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) &&
(port->partner_oper.port_state & LACP_STATE_COLLECTING)) {
port->sm_mux_state = AD_MUX_DISTRIBUTING;Entering that state then does:
case AD_MUX_DISTRIBUTING: port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; ad_enable_collecting_distributing(port, update_slave_arr);
As far as I can tell, the __enable_port() path does not clear should_notify_rx, because the slave's Rx state is already enabled.
Any LACPDU sent before RTNL is obtained, such as the periodic one, would then carry Distributing=1 and Collecting=0. The 802.1AX mux machine never produces that combination.
Would it make sense to also mask LACP_STATE_DISTRIBUTING while the notification is pending?
[Severity: Low]
Only the transmitted copy is masked here. While the notification is pending, procfs, sysfs and netlink still report port->actor_oper_port_state with Collecting set. For example, bond_info_show_slave() in bond_procfs.c does:
seq_puts(seq, "details actor lacp pdu:\n"); ... seq_printf(seq, " port state: %d\n", port->actor_oper_port_state);
The sysfs ad_actor_oper_port_state file and the netlink IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE attribute are named after actor_oper_port_state, so they report what their names say. The procfs block, however, is labelled as the actor LACP PDU, and for a short time it now shows a different value from the one on the wire.
Is this difference intended? If so, should the procfs label be adjusted or the difference documented?
Later in this series, "selftests: bonding: Test that Collecting is advertised after notification" adds test coverage for the transmitted LACPDU. Its collecting_advertise() captures LACPDUs and checks that Collecting is only advertised after the 0x1f notification. That test also suggests the notification is meant to carry the unmasked state.
drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_port(struct port *port) · line 924
Quoted 3 lines
drivers/net/bonding/bond_3ad.c +0
-0slave_dbg (port->slave->bond->dev, port->slave->dev,"update lacpdu: actor port state %x\n" , port->actor_oper_port_state);
[Severity: Low]
Should this debug message print lacpdu->actor_state now?
While the Rx notification is pending, the message prints port->actor_oper_port_state with Collecting set (for example 0x1f). The LACPDU on the wire carries 0x0f. Before this patch the two values were always the same.
Printing lacpdu->actor_state, or both values, would keep the message in line with what is sent.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118083442.1061289-1-idosch%40nvidia.com
Ido Schimmel
maintainerRe: [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled
tl;dr - I believe the patch is fine as-is.
Quoted 64 lines · On Thu, Nov 19, 2026 at 09:19:42AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In
__update_lacpdu_from_port()(drivers/net/bonding/bond_3ad.c), the patch clearsLACP_STATE_COLLECTINGinlacpdu->actor_statewhen…
- [Low] While the Rx notification is pending, procfs ("details actor lacp
pdu: port state"), sysfsad_actor_oper_port_stateand netlink…
- [Low]__update_lacpdu_from_port()masks onlyLACP_STATE_COLLECTINGwhile the Rx notification is pending.--
bonding: 3ad: Advertise Collecting only after collection is enabled
When coupled control is disabled, this commit clears the Collecting bit in transmitted LACPDUs while the port's Rx state change notification is still pending. Once the notification is delivered,
ad_tx_machine()sets ntt so that a new LACPDU advertising Collecting goes out.Quoted 4 lines
drivers/net/bonding/bond_3ad.c +0
-0[ ... ]
drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_port(struct port *port) · line 921
Quoted 7 lines
drivers/net/bonding/bond_3ad.c +3
-0@@ -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 ;[Severity: Low]
This masks only Collecting. Can the transmittedactor_statehave Distributing set while Collecting is cleared?Suppose
rtnl_trylock()fails inbond_3ad_state_machine_handler()at the end of the run that enteredAD_MUX_COLLECTING. Thenshould_notify_rxstays set. On the next tick,ad_mux_machine()can move toAD_MUX_DISTRIBUTINGbased only on the partner's state:case AD_MUX_COLLECTING: if (!__port_move_to_attached_state(port)) { if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) && (port->partner_oper.port_state & LACP_STATE_COLLECTING)) { port->sm_mux_state = AD_MUX_DISTRIBUTING;Entering that state then does:
case AD_MUX_DISTRIBUTING: port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; ad_enable_collecting_distributing(port, update_slave_arr);As far as I can tell, the
__enable_port()path does not clearshould_notify_rx, because the slave's Rx state is already enabled.
Quoted 6 lines
Any LACPDU sent before RTNL is obtained, such as the periodic one, would then carry Distributing=1 and Collecting=0. The 802.1AX mux machine never produces that combination.
Would it make sense to also mask
LACP_STATE_DISTRIBUTINGwhile the notification is pending?
Looking at 802.1AX, I can't find where it says that transmitting "Distributing=1 and Collecting=0" is invalid and it also shouldn't matter for our partner because the partner never looks at our Distributing bit. It's only looking at our Synchronization and Collecting bits and the latter is correctly turned off until collection is enabled in both software and hardware, which is what matters here.
And I don't think that it makes sense to mask LACP_STATE_DISTRIBUTING in our LACPDUs when in practice the port is already transmitting (from the software data path, not the hardware data path).
If anything, it makes more sense to keep the mux machine at AD_MUX_COLLECTING when the Rx notification is still pending, but I don't understand what it buys us and I would rather follow up on this than send the entire series again.
Quoted 12 lines
[Severity: Low]
Only the transmitted copy is masked here. While the notification is pending, procfs, sysfs and netlink still reportport->actor_oper_port_statewith Collecting set. For example,bond_info_show_slave()inbond_procfs.cdoes:seq_puts(seq, "details actor lacp pdu:\n"); ... seq_printf(seq, " port state: %d\n", port->actor_oper_port_state);
Quoted 5 lines
The sysfs
ad_actor_oper_port_statefile and the netlinkIFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATEattribute are named afteractor_oper_port_state, so they report what their names say. The procfs block, however, is labelled as the actor LACP PDU, and for a short time it now shows a different value from the one on the wire.
This could happen even before the patch. LACPDUs are sent at a rate of at most three per second. First the actor state changes and only later it's visible on the wire.
Quoted 3 lines
Is this difference intended? If so, should the procfs label be adjusted or the difference documented?
No, it shouldn't be adjusted. It always reported the actor state rather than what was encoded in the State byte of the last LACPDU.
Quoted 14 lines
Later in this series, "selftests: bonding: Test that Collecting is advertised after notification" adds test coverage for the transmitted LACPDU. Its
collecting_advertise()captures LACPDUs and checks that Collecting is only advertised after the0x1fnotification. That test also suggests the notification is meant to carry the unmasked state.drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_port(struct port *port) · line 924
Quoted 3 lines
drivers/net/bonding/bond_3ad.c +0
-0slave_dbg (port->slave->bond->dev, port->slave->dev,"update lacpdu: actor port state %x\n" , port->actor_oper_port_state);[Severity: Low]
Should this debug message printlacpdu->actor_statenow?
Quoted 7 lines
While the Rx notification is pending, the message prints
port->actor_oper_port_statewith Collecting set (for example0x1f). The LACPDU on the wire carries0x0f. Before this patch the two values were always the same.Printing
lacpdu->actor_state, or both values, would keep the message in line with what is sent.
The message prints the port's state, as it did before this patch. The difference is transient and only happens when coupled control is disabled, so I don't think it's worth changing.
Ido Schimmel
maintainerPATCH 6/6 selftests: bonding: Test that Collecting is advertised after notification
In reply to Ido SchimmelTest 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 ]
---
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(-)
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +51 -2
@@ -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
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] collecting_advertise() in tools/testing/selftests/drivers/net/ bonding/bond_lacp_independent_control.sh can take the wrong…
--
selftests: bonding: Test that Collecting is advertised after notification
This patch adds a collecting_advertise test to bond_lacp_independent_control.sh. With coupled control disabled, the test checks that the Collecting bit is only advertised in a transmitted LACPDU after the Rx state change notification was emitted. It also switches the partner to a slow LACP rate so that the port is not rate limited when it enters COLLECTING state.
Quoted 4 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +0
-0
[ ... ]
Quoted 19 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +15
-0@@ -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 $!
[ ... ]
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh collecting_notify() · line 209
Quoted 6 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +6
-0+ 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"
[Severity: Medium]
Can notify_ts in collecting_advertise() pick up the timestamp of an unrelated link notification instead of the $h1 one?
The monitor runs as "ip -ts -o -d monitor link dev $h1". In iproute2, accept_msg() in ipmonitor calls print_headers() for every RTM_NEWLINK. With -ts, that prints "[<time>] " with no newline.
print_linkinfo() then returns early and prints nothing when filter.ifindex is set and ifi->ifi_index != filter.ifindex, which is the case for any device other than $h1. The timestamp of the filtered message is therefore left at the start of the next printed line.
With -o, the matching line can then look like this:
[ts_other] [ts_h1] N: $h1: ... ad_actor_oper_port_state 31 ...
The sed above takes the first bracket, ts_other. That timestamp is older than the real $h1 notification.
Without "bonding: 3ad: Advertise Collecting only after collection is enabled", the Collecting LACPDU goes out only a short time (at most about one tick) before the notification. So any RTM_NEWLINK for another device between the monitor start and the $h1 0x1f notification would make notify_ts smaller than lacpdu_ts. In that case the check below passes even though the bug is present:
((lacpdu_ts > notify_ts))
That window covers the sleep 1 plus the wait for the partner's next LACPDU.
The test runs in the init netns, so link events on other host interfaces can land in that window. Examples are NetworkManager or docker veths, carrier changes, and IPv6 ifinfo notifications.
One option is to drop the dev filter and grep for the "$h1:" line, so every printed line has its own timestamp. Another is to take the last bracketed timestamp on the line instead of the first. Would either of these make the check more robust?
Quoted 3 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +3
-0+ + log_test "Collecting advertised after notification" +}
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118083442.1061289-1-idosch%40nvidia.com
Ido Schimmel
maintainerRe: [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification
tl;dr - I believe the patch is fine as-is.
Quoted 70 lines · On Thu, Nov 19, 2026 at 09:19:43AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium]
collecting_advertise()intools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.shcan take the wrong…--
selftests: bonding: Test that Collecting is advertised after notification
This patch adds a
collecting_advertisetest tobond_lacp_independent_control.sh. With coupled control disabled, the test checks that the Collecting bit is only advertised in a transmitted LACPDU after the Rx state change notification was emitted. It also switches the partner to a slow LACP rate so that the port is not rate limited when it enters COLLECTING state.Quoted 4 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +0
-0[ ... ]
Quoted 19 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +15
-0@@ -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 $![ ... ]
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh collecting_notify() · line 209
Quoted 6 lines
tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh +6
-0+ 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"[Severity: Medium]
Can
notify_tsincollecting_advertise()pick up the timestamp of an unrelated link notification instead of the $h1 one?The monitor runs as "ip -ts -o -d monitor link dev $h1". In iproute2,
accept_msg()in ipmonitor callsprint_headers()for everyRTM_NEWLINK. With -ts, that prints "[<time>] " with no newline.
Quoted 8 lines
print_linkinfo()then returns early and prints nothing when filter.ifindex is set andifi->ifi_index!= filter.ifindex, which is the case for any device other than $h1. The timestamp of the filtered message is therefore left at the start of the next printed line.With -o, the matching line can then look like this:
[ts_other] [ts_h1] N: $h1: ... ad_actor_oper_port_state 31 ...
This was fixed over two years ago by iproute2 commit 554ea3649dd1 ("ip:
do not print stray prefixes in monitor mode") in v6.11.