[PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode
From: Hangbin Liu
Date: Tue Dec 01 2026 - 01:30:01 EST
From: Hangbin Liu <liuhangbin@xxxxxxxxxx>
The MII monitor uses the usable-slave array to decide whether to
bypass updelay. When no slave can transmit, the first recovering
slave should become usable without waiting for updelay (bonding.rst
section 13.1 paragraph 4). When another slave can still transmit,
the recovering slave should wait.
In broadcast mode, the array is rebuilt when a slave is added or
removed, but not when its link state changes. A stale empty array can
make a recovering slave bypass updelay while another slave is still
forwarding. A stale nonempty array can make the first recovering
slave wait even though no slave can transmit.
Rebuild the arrays upon MII link-state changes. The ARP monitor
`bond_loadbalance_arp_mon` also needs to be updated, since the bonding
monitor mode may be changed at runtime. Apply the same logic in
`bond_open()` and `bond_slave_netdev_event()`.
This relies on the preceding revert of commit 45fc134bcfad ("bonding: do
not set usable_slaves for broadcast mode") to publish the refreshed
usable-slave array.
Fixes: e0caeb24f538 ("net: bonding: update the slave array for broadcast mode")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Hangbin Liu <liuhangbin@xxxxxxxxxx>
---
For Sashiko:
When the bond mode switch from balance-xor to balance-rr, or broadcast
to balance-rr, the published usable_slaves is not changed. This is
issue for balance-rr and will be addressed in another patch.
---
drivers/net/bonding/bond_main.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index d6675e87d06b..a8c79fa9f5bf 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2780,6 +2780,7 @@ static void bond_miimon_link_change(struct bonding *bond,
bond_alb_handle_link_change(bond, slave, link);
break;
case BOND_MODE_XOR:
+ case BOND_MODE_BROADCAST:
bond_update_slave_arr(bond, NULL);
break;
}
@@ -3588,7 +3589,8 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)
if (slave_state_changed) {
bond_slave_state_change(bond);
- if (BOND_MODE(bond) == BOND_MODE_XOR)
+ if (BOND_MODE(bond) == BOND_MODE_XOR ||
+ BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, NULL);
}
if (do_failover) {
@@ -4010,7 +4012,8 @@ static int bond_slave_netdev_event(unsigned long event,
* events. If these (miimon/arpmon) parameters are configured
* then array gets refreshed twice and that should be fine!
*/
- if (bond_mode_can_use_xmit_hash(bond))
+ if (bond_mode_can_use_xmit_hash(bond) ||
+ BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, NULL);
break;
case NETDEV_CHANGEMTU:
@@ -4411,7 +4414,8 @@ static int bond_open(struct net_device *bond_dev)
static_branch_inc(&bond_bcast_neigh_enabled);
}
- if (bond_mode_can_use_xmit_hash(bond))
+ if (bond_mode_can_use_xmit_hash(bond) ||
+ BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, NULL);
return 0;
--
2.56.0