* [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode
@ 2026-12-01 6:29 Hangbin Liu
2026-12-01 6:29 ` [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Hangbin Liu @ 2026-12-01 6:29 UTC (permalink / raw)
To: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Tonghao Zhang, Nikolay Aleksandrov,
Shuah Khan
Cc: jiangjiehua (A), Hangbin Liu, netdev, linux-kernel,
linux-kselftest, Hangbin Liu, stable
This patchset fixes updelay handling for bonding broadcast mode (mode 3)
to align with bonding documentation section 13.1 paragraph 4: when a
bond has no active links, the first link that comes up must be reused
immediately even if updelay is configured; when usable links exist,
updelay must be honored.
Commit 45fc134bcfad ("bonding: do not set usable_slaves for broadcast
mode") tried to fix the second half of that rule by never updating
usable_slaves in broadcast mode. That made ignore_updelay permanently
false, so updelay was always applied and a broadcast bond with no
active links could not recover within the miimon window when one usable
slave up.
We revert 45fc134bcfad to restore the enslave/release side of the
usable_slaves updates, and add the missing bond_miimon_link_change()
case so the snapshot also tracks link-state transitions. Both halves
are needed:
- revert alone: the snapshot is only rebuilt on enslave/release, so
batch enslave with updelay (new slaves start in BOND_LINK_BACK)
leaves count == 0 forever and updelay is never honored, even once
other slaves are usable;
- link_change case alone: with 45fc134bcfad applied,
bond_set_slave_arr() discards the refreshed array for broadcast.
A selftest is added to cover mode 3; the existing mode 1 and mode 2
recovery-updelay tests are merged into a single script covering
modes 1, 2 and 3.
Before revert 45fc134bcfad:
TEST: mode (3) bond recovery [FAIL]
No connectivity
TEST: mode (3) bond recovery [FAIL]
No connectivity
TEST: mode (3) bond recovery [FAIL]
No connectivity
After revert 45fc134bcfad:
TEST: mode (3) bond recovery [ OK ]
TEST: mode (3) bond recovery [ OK ]
TEST: mode (3) bond recovery [ OK ]
For the second patch, I use test script
```
ip link add veth0 type veth peer name veth0p
ip link add veth1 type veth peer name veth1p
ip link set veth0p up
ip link set veth1p up
ip link add bond0 type bond mode broadcast miimon 100 updelay 1000
ip link set veth0 down
ip link set veth1 down
ip link set veth0 master bond0 && ip link set veth1 master bond0
ip link set bond0 up
sleep 2
dmesg -C
# Test A — bullet 1: batch enslave, snapshot stuck at count == 0,
# updelay never honored
ip link set veth0p down
sleep 2
ip link set veth0p up
sleep 1
dmesg | tail -n 5
# Test B — bullet 2: stale non-empty snapshot, recovery delayed with
# zero usable links
ip link set veth0 nomaster
ip link set veth1 nomaster
ip link set veth0 master bond0
sleep 2 # wait veth0 up
ip link set veth1 master bond0
sleep 2 # veth1 comes up after its own updelay; snapshot stays
# drop both links (bond has zero usable links after this)
ip link set veth0p down
ip link set veth1p down
sleep 2
ip link set veth0p up
sleep 2
dmesg | tail -n 5
```
With revert only:
Test A:
[ 13.190593] bond0: (slave veth0): link status definitely down, disabling slave
[ 15.165875] bond0: (slave veth0): link status up, enabling it in 0 ms
[ 15.165919] bond0: (slave veth0): link status definitely up, 10000 Mbps full duplex
Test B:
[ 20.366724] bond0: (slave veth1): link status definitely down, disabling slave
[ 20.366957] bond0: now running without any active interface!
[ 22.341960] bond0: (slave veth0): link status up, enabling it in 1000 ms
[ 23.382194] bond0: (slave veth0): link status definitely up, 10000 Mbps full duplex
[ 23.382428] bond0: active interface up!
With the second patch
Test A:
[ 6.208526] bond0: (slave veth0): link status definitely down, disabling slave
[ 8.184359] bond0: (slave veth0): link status up, enabling it in 1000 ms
Test B:
[ 13.384852] bond0: (slave veth1): link status definitely down, disabling slave
[ 13.385093] bond0: now running without any active interface!
[ 15.360849] bond0: (slave veth0): link status up, enabling it in 0 ms
We can see when there is active slave, the second slave follow the
updelay rule (Test A). When there is no active slave, the first up
slave will be in use immediately (Test B).
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
Changes in v2:
- For patch 2, also rebuild the array in arp monitor in case user
changed from arp to miimon.
- Link to v1: https://patch.msgid.link/20261126-bond_broadcast_updelay-v1-0-188e5538d6ca@kylinos.cn
---
Hangbin Liu (3):
Revert "bonding: do not set usable_slaves for broadcast mode"
bonding: update slave array on link change for broadcast mode
selftests: bonding: add recovery updelay test for broadcast mode
drivers/net/bonding/bond_main.c | 23 ++++++-----
.../testing/selftests/drivers/net/bonding/Makefile | 3 +-
.../drivers/net/bonding/mode-2-recovery-updelay.sh | 45 ----------------------
...e-1-recovery-updelay.sh => recovery-updelay.sh} | 13 +++----
4 files changed, 18 insertions(+), 66 deletions(-)
---
base-commit: 1ab3fb564f20b78615a6d88b8c90da292f29e227
change-id: 20261126-bond_broadcast_updelay-cc4cfb6e0e37
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" 2026-12-01 6:29 [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu @ 2026-12-01 6:29 ` Hangbin Liu 2026-12-03 6:29 ` netdev-bot+sashiko 2026-12-01 6:29 ` [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu ` (2 subsequent siblings) 3 siblings, 1 reply; 9+ messages in thread From: Hangbin Liu @ 2026-12-01 6:29 UTC (permalink / raw) To: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tonghao Zhang, Nikolay Aleksandrov, Shuah Khan Cc: jiangjiehua (A), Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu, stable From: Hangbin Liu <liuhangbin@kylinos.cn> This reverts commit 45fc134bcfadde456639c1b1e206e6918d69a553. The reverted commit 45fc134bcfad ("bonding: do not set usable_slaves for broadcast mode") assumes the bond updelay always applies. However, based on bonding.rst section 13.1 paragraph 4 and commit f8a65ab2f3ff ("bonding: fix link recovery in mode 2 when updelay is nonzero"), when a slave is enslaved and there are no active slaves, the slave should become usable immediately once its link comes up, updelay should be ignored. Before this revert: with no active interfaces, the only slave still waited out the 1000 ms updelay before being brought into use. [ 154.846629] bond0: (slave veth0): link status definitely down, disabling slave [ 154.849879] bond0: now running without any active interface! [ 159.544736] bond0: (slave veth0): link status up, enabling it in 1000 ms [ 160.586299] bond0: (slave veth0): link status definitely up, 10000 Mbps full duplex [ 160.603278] bond0: active interface up! After this revert: the first slave can be used immediately on link up. Subsequent slave veth2 still honor the 1000 ms updelay. [ 94.106425] bond0: (slave veth0): link status definitely down, disabling slave [ 94.109130] bond0: now running without any active interface! [ 98.272494] bond0: (slave veth0): link status up, enabling it in 0 ms [ 98.273279] bond0: (slave veth0): link status definitely up, 10000 Mbps full duplex [ 98.275056] bond0: active interface up! [ 110.855705] bond0: (slave veth2): Enslaving as an active interface with an up link [ 111.904688] bond0: (slave veth2): link status definitely up, 10000 Mbps full duplex [ 114.608488] bond0: (slave veth2): link status definitely down, disabling slave [ 117.624491] bond0: (slave veth2): link status up, enabling it in 1000 ms [ 118.664636] bond0: (slave veth2): link status definitely up, 10000 Mbps full duplex The stale-empty side of the problem that revert this one is addressed by the follow-up patch in this series, "bonding: update slave array on link change for broadcast mode", which rebuilds the array on link transitions, together they keep ignore_updelay correct in both directions. Cc: stable@vger.kernel.org Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> --- drivers/net/bonding/bond_main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 042d7c75548f..d6675e87d06b 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -5140,18 +5140,13 @@ static void bond_set_slave_arr(struct bonding *bond, { struct bond_up_slave *usable, *all; - all = rtnl_dereference(bond->all_slaves); - rcu_assign_pointer(bond->all_slaves, all_slaves); - kfree_rcu(all, rcu); - - if (BOND_MODE(bond) == BOND_MODE_BROADCAST) { - kfree_rcu(usable_slaves, rcu); - return; - } - usable = rtnl_dereference(bond->usable_slaves); rcu_assign_pointer(bond->usable_slaves, usable_slaves); kfree_rcu(usable, rcu); + + all = rtnl_dereference(bond->all_slaves); + rcu_assign_pointer(bond->all_slaves, all_slaves); + kfree_rcu(all, rcu); } static void bond_reset_slave_arr(struct bonding *bond) -- 2.56.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" 2026-12-01 6:29 ` [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu @ 2026-12-03 6:29 ` netdev-bot+sashiko 0 siblings, 0 replies; 9+ messages in thread From: netdev-bot+sashiko @ 2026-12-03 6:29 UTC (permalink / raw) To: hangbin.liu Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, tonghao, razor, shuah, jiangjiehua1, netdev, linux-kernel, linux-kselftest Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 1 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] Looking only at this commit: after the revert, bond_set_slave_arr() publishes bond->usable_slaves for… - [Low] bonding: missing Fixes trailer on revert of commit 45fc134bcfad -- Revert "bonding: do not set usable_slaves for broadcast mode" This reverts 45fc134bcfad so that bond_set_slave_arr() publishes bond->usable_slaves in broadcast mode again. The goal is to let bond_miimon_inspect() skip updelay when no slaves are usable. The commit message says the follow-up patch, "bonding: update slave array on link change for broadcast mode", handles the stale array side. > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 042d7c75548fa..d6675e87d06b6 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -5140,18 +5140,13 @@ static void bond_set_slave_arr(struct bonding *bond, > { > struct bond_up_slave *usable, *all; > > - all = rtnl_dereference(bond->all_slaves); > - rcu_assign_pointer(bond->all_slaves, all_slaves); > - kfree_rcu(all, rcu); > - > - if (BOND_MODE(bond) == BOND_MODE_BROADCAST) { > - kfree_rcu(usable_slaves, rcu); > - return; > - } > - > usable = rtnl_dereference(bond->usable_slaves); > rcu_assign_pointer(bond->usable_slaves, usable_slaves); [Severity: Low] The changelog identifies the reverted commit and carries Cc: stable, but there is no Fixes: trailer. This revert fixes a regression that 45fc134bcfad introduced. bond_set_slave_arr() stopped publishing bond->usable_slaves in broadcast mode, so bond_miimon_inspect() could no longer set ignore_updelay. Shouldn't this carry a Fixes: tag pointing at 45fc134bcfad ("bonding: do not set usable_slaves for broadcast mode")? This matters for more than tidiness. Stable backport tooling uses Fixes: to decide which trees need a patch. Patch 2/3 in this series carries Fixes: e0caeb24f538 ("net: bonding: update the slave array for broadcast mode") and depends on this revert. Suppose only the follow-up is picked for a tree that already has 45fc134bcfad. The broadcast early return in bond_set_slave_arr() is still there, so usable_slaves stays NULL. The new rebuild calls would then not change the ignore_updelay decision at all. Could the Fixes: tag be added in the next revision? [Severity: Medium] On its own, can this commit leave a stale usable_slaves array in broadcast mode? At this point in the series, broadcast mode rebuilds the array only in bond_enslave() and __bond_release_one(). bond_miimon_link_change() only rebuilds it for BOND_MODE_XOR: bond_miimon_link_change() { ... case BOND_MODE_XOR: bond_update_slave_arr(bond, NULL); break; ... } bond_open(), bond_slave_netdev_event() and the ARP load-balance monitor only check bond_mode_can_use_xmit_hash(), so they skip broadcast too. With miimon and updelay set, bond_enslave() puts a slave that already has carrier into BOND_LINK_BACK: if (bond->params.updelay) { bond_set_slave_link_state(new_slave, BOND_LINK_BACK, ... That means the array published at enslave time has count == 0. bond_miimon_inspect() then sees this on every later pass: if (usable_slaves && usable_slaves->count == 0) ignore_updelay = true; Wouldn't updelay be ignored permanently here? That is the behaviour 45fc134bcfad fixed. It can also go the other way. An array built while slaves were up stays non-empty after every link drops. Wouldn't the first slave to recover still wait out the full updelay, which is the symptom this revert is meant to fix? The next patch, "bonding: update slave array on link change for broadcast mode", resolves this. It adds BOND_MODE_BROADCAST handling to bond_miimon_link_change(), bond_loadbalance_arp_mon(), bond_slave_netdev_event() and bond_open(). Both patches carry Cc: stable, but the dependency is only stated in prose. Could the revert be squashed into the follow-up, or could the follow-up be referenced explicitly for stable? Either way, a bisect or a backport of only this commit would not land on the broken intermediate state. > kfree_rcu(usable, rcu); > + > + all = rtnl_dereference(bond->all_slaves); > + rcu_assign_pointer(bond->all_slaves, all_slaves); > + kfree_rcu(all, rcu); > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-bond_broadcast_updelay-v2-0-969e1844f2c4%40kylinos.cn ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode 2026-12-01 6:29 [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu 2026-12-01 6:29 ` [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu @ 2026-12-01 6:29 ` Hangbin Liu 2026-12-03 6:29 ` netdev-bot+sashiko 2026-12-01 6:29 ` [PATCH net v2 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu 2026-12-01 6:34 ` [PATCH net v2 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo 3 siblings, 1 reply; 9+ messages in thread From: Hangbin Liu @ 2026-12-01 6:29 UTC (permalink / raw) To: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tonghao Zhang, Nikolay Aleksandrov, Shuah Khan Cc: jiangjiehua (A), Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu, stable From: Hangbin Liu <liuhangbin@kylinos.cn> 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@vger.kernel.org Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> --- 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 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode 2026-12-01 6:29 ` [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu @ 2026-12-03 6:29 ` netdev-bot+sashiko 0 siblings, 0 replies; 9+ messages in thread From: netdev-bot+sashiko @ 2026-12-03 6:29 UTC (permalink / raw) To: hangbin.liu Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, tonghao, razor, shuah, jiangjiehua1, netdev, linux-kernel, linux-kselftest Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 (2) · Low: 0 (2) 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] In balance-rr, updelay is ignored for good after the bond has been switched from broadcast mode. - [Medium] bonding: stale usable_slaves in bond_change_active_slave() on LINK_BACK promotion Pre-existing issues: - [Medium] This problem wasn't introduced by this patch, but ALB mode and TLB with tlb_dynamic_lb=1 have the same stale usable_slaves problem… - [Medium] This problem wasn't introduced by this patch, but balance-rr never implements the rule in bonding.rst section 13.1 ('when a bonding… - [Low] This problem wasn't introduced by this patch, but two comments are stale. - [Low] This problem wasn't introduced by this patch, but bond_miimon_inspect() reads usable_slaves->count with a plain load… -- bonding: update slave array on link change for broadcast mode In broadcast mode, this patch rebuilds the usable and all slave arrays on MII and ARP monitor link-state changes, in bond_open(), and on slave NETDEV_UP/CHANGE/DOWN events. The aim is to keep usable_slaves current so that bond_miimon_inspect() decides correctly whether to bypass updelay. It relies on the preceding revert that makes broadcast mode publish usable_slaves again. > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index d6675e87d06b6..a8c79fa9f5bf2 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; > } [Severity: Medium] Does this cover every place where a broadcast slave becomes BOND_LINK_UP? bond_change_active_slave() can move a slave that is still in BOND_LINK_BACK straight to BOND_LINK_UP, which skips the rest of its updelay. In that path it resets new_active->delay and calls bond_set_slave_link_state(). After that it only calls bond_3ad_handle_link_change() for 802.3ad and bond_alb_handle_link_change() for TLB/ALB. Nothing rebuilds the arrays for broadcast or xor. Here is one sequence with updelay > 0. Slave A is curr_active_slave and is the only slave that can transmit. Slave B is in BOND_LINK_BACK with delay < updelay. Then A loses carrier: bond_miimon_commit() bond_miimon_link_change(bond, A, BOND_LINK_DOWN) bond_update_slave_arr() <- B is BACK, count == 0 bond_select_active_slave() bond_find_best_slave() <- returns B bond_change_active_slave(bond, B) bond_set_slave_link_state(B, BOND_LINK_UP, ...) Releasing A through __bond_release_one() has the same result. That path rebuilds the array with A skipped, and only then calls bond_select_active_slave(). B is now forwarding, but usable_slaves->count is still 0. B's link is already BOND_LINK_UP, so later bond_miimon_inspect() passes skip it and bond_miimon_commit() never handles it. The array stays empty until some other link event happens. The next slave to recover then sees count == 0 in bond_miimon_inspect(). It sets ignore_updelay and skips updelay while B is still forwarding. That is the case the commit message sets out to fix. Balance-xor already has this hole. There the empty array also makes bond_3ad_xor_xmit() drop packets while B is up. Would it be the right fix to call bond_miimon_link_change(bond, new_active, BOND_LINK_UP) from bond_change_active_slave(), in place of the open-coded 802.3ad and TLB/ALB calls? Or should the callers rebuild the array after bond_select_active_slave()? [Severity: Medium] This is a pre-existing issue, but do ALB mode and TLB with tlb_dynamic_lb=1 have the same stale usable_slaves problem that this patch fixes for broadcast? bond_mode_can_use_xmit_hash() includes TLB and ALB. So enslave, release, bond_open() and NETDEV_UP/CHANGE/DOWN all rebuild the array for those modes. On MII link transitions, though, the TLB/ALB case goes through bond_alb_handle_link_change(). That function rebuilds only for non-dynamic TLB: drivers/net/bonding/bond_alb.c:bond_alb_handle_link_change() { ... if (bond_is_nondyn_tlb(bond)) { if (bond_update_slave_arr(bond, NULL)) ... } This condition is never true for ALB, because bond_option_mode_set() forces tlb_dynamic_lb=1. It is not true for dynamic TLB either. Here is one sequence. Carrier-up raises NETDEV_CHANGE, which is handled promptly because bond slaves are lag ports. The array is rebuilt while slave->link is still DOWN or BACK, so bond_slave_can_tx() leaves the slave out. miimon later commits BOND_LINK_UP, and nothing rebuilds the array. Wouldn't the array then stay empty while a slave is forwarding? The next recovering slave would then bypass updelay in bond_miimon_inspect(). [Severity: Low] This is a pre-existing issue, but bond_miimon_inspect() reads usable_slaves->count with a plain load while holding only RCU: usable_slaves = rcu_dereference(bond->usable_slaves); if (usable_slaves && usable_slaves->count == 0) ignore_updelay = true; bond_skip_slave() can change count in place on the already published array, holding only RTNL. This happens on the ENOMEM path of bond_update_slave_arr() when it is called from __bond_release_one(): WRITE_ONCE(slaves->count, slaves->count - 1); The two sides share no lock and only one access is marked, so KCSAN would report this pair. Other readers already use READ_ONCE(slaves->count), for example bond_xmit_broadcast(), bond_xmit_3ad_xor_slave_get(), bond_xdp_xmit_3ad_xor_slave_get() and __bond_sk_get_lower_dev(). Should bond_miimon_inspect() use READ_ONCE() here too? [ ... ] > @@ -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; [Severity: Medium] Can a bond that is switched from broadcast to balance-rr end up ignoring updelay for good? With the preceding revert, broadcast mode publishes bond->usable_slaves again. Releasing the last broadcast slave goes through: __bond_release_one() bond_update_slave_arr(bond, slave) bond_set_slave_arr() <- publishes non-NULL usable_slaves, count == 0 The mode option requires BOND_OPTFLAG_NOSLAVES | BOND_OPTFLAG_IFDOWN. But neither bond_option_mode_set() nor bond_close() resets usable_slaves or all_slaves, so the count == 0 array carries over into balance-rr. In balance-rr, nothing rebuilds that array: - enslave, release, bond_open() and bond_slave_netdev_event() are gated on bond_mode_can_use_xmit_hash() || BROADCAST. - bond_miimon_link_change() has no rr case. The check in bond_miimon_inspect() is then true on every pass: if (usable_slaves && usable_slaves->count == 0) ignore_updelay = true; As a result, every recovering rr slave gets delay = 0, even while other slaves are still forwarding. This looks like the case the commit message says it fixes: A stale empty array can make a recovering slave bypass updelay while another slave is still forwarding. The xor to rr path already had this problem. The broadcast to rr variant is new with this series. It is only mentioned in the "For Sashiko" note below the --- line, which won't reach the git log or stable reviewers, even though the patch carries Cc: stable. Should the arrays be reset on mode change or in bond_close()? Or should the commit message at least note this limitation? [Severity: Medium] This is a pre-existing issue, but does balance-rr ever follow the bonding.rst section 13.1 rule that the commit message cites? Note that when a bonding interface has no active links, the driver will immediately reuse the first link that goes up, even if the updelay parameter has been specified bond_miimon_inspect() derives ignore_updelay from bond->usable_slaves for every mode except active-backup. No bond_update_slave_arr() call site covers BOND_MODE_ROUNDROBIN: - enslave, release, open and netdev events are gated on xmit_hash || BROADCAST. - bond_miimon_link_change() covers 8023AD/TLB/ALB/XOR/BROADCAST. - bond_loadbalance_arp_mon() covers XOR/BROADCAST. A bond that has always been in rr mode therefore has usable_slaves == NULL, and ignore_updelay stays false. Doesn't the first recovering link then wait the full updelay, even though no slave can transmit? If the bond was earlier in xor or broadcast mode, the opposite failure described above happens instead. [Severity: Low] This isn't a bug introduced by this patch, but two existing comments no longer match how broadcast mode uses the arrays. The header comment of bond_update_slave_arr() leaves out BOND_MODE_BROADCAST: /* Build the usable slaves array in control path for modes that use xmit-hash * to determine the slave interface - * (a) BOND_MODE_8023AD * (b) BOND_MODE_XOR * (c) (BOND_MODE_TLB || BOND_MODE_ALB) && tlb_dynamic_lb == 0 The comment in bond_enslave() gives all_slaves as the only reason for broadcast: /* broadcast mode uses the all_slaves to loop through slaves. */ The new broadcast call sites, however, exist to keep usable_slaves current for bond_miimon_inspect(). Could these comments be updated as well? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-bond_broadcast_updelay-v2-0-969e1844f2c4%40kylinos.cn ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v2 3/3] selftests: bonding: add recovery updelay test for broadcast mode 2026-12-01 6:29 [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu 2026-12-01 6:29 ` [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu 2026-12-01 6:29 ` [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu @ 2026-12-01 6:29 ` Hangbin Liu 2026-12-03 6:29 ` netdev-bot+sashiko 2026-12-01 6:34 ` [PATCH net v2 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo 3 siblings, 1 reply; 9+ messages in thread From: Hangbin Liu @ 2026-12-01 6:29 UTC (permalink / raw) To: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tonghao Zhang, Nikolay Aleksandrov, Shuah Khan Cc: jiangjiehua (A), Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu From: Hangbin Liu <liuhangbin@kylinos.cn> Add a recovery updelay test for bonding mode 3. Merge all related tests into a single test file. Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> --- .../testing/selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/mode-2-recovery-updelay.sh | 45 ---------------------- ...e-1-recovery-updelay.sh => recovery-updelay.sh} | 13 +++---- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index e337c099fb40..c186310c2d6e 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -15,9 +15,8 @@ TEST_PROGS := \ bond_stacked_header_parse.sh \ bond_vlan_real_dev.sh \ dev_addr_lists.sh \ - mode-1-recovery-updelay.sh \ - mode-2-recovery-updelay.sh \ netcons_over_bonding.sh \ + recovery-updelay.sh \ # end of TEST_PROGS TEST_FILES := \ diff --git a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh deleted file mode 100755 index 2d275b3e47dd..000000000000 --- a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 - -# Regression Test: -# When the bond is configured with down/updelay and the link state of -# slave members flaps if there are no remaining members up the bond -# should immediately select a member to bring up. (from bonding.txt -# section 13.1 paragraph 4) -# -# +-------------+ +-----------+ -# | client | | switch | -# | | | | -# | +--------| link1 |-----+ | -# | | +-------+ | | -# | | | | | | -# | | +-------+ | | -# | | bond | link2 | Br0 | | -# +-------------+ +-----------+ -# 172.20.2.1 172.20.2.2 - - -REQUIRE_MZ=no -REQUIRE_JQ=no -NUM_NETIFS=0 -lib_dir=$(dirname "$0") -source "$lib_dir"/../../../net/forwarding/lib.sh -source "$lib_dir"/lag_lib.sh - -cleanup() -{ - lag_cleanup -} - -trap cleanup 0 1 2 - -lag_setup_network -test_bond_recovery mode 2 miimon 100 updelay 0 -test_bond_recovery mode 2 miimon 100 updelay 200 -test_bond_recovery mode 2 miimon 100 updelay 500 -test_bond_recovery mode 2 miimon 100 updelay 1000 -test_bond_recovery mode 2 miimon 100 updelay 2000 -test_bond_recovery mode 2 miimon 100 updelay 5000 -test_bond_recovery mode 2 miimon 100 updelay 10000 - -exit "$EXIT_STATUS" diff --git a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/recovery-updelay.sh similarity index 72% rename from tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh rename to tools/testing/selftests/drivers/net/bonding/recovery-updelay.sh index 9d26ab4cad0b..05edf9915cc0 100755 --- a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh +++ b/tools/testing/selftests/drivers/net/bonding/recovery-updelay.sh @@ -34,12 +34,11 @@ cleanup() trap cleanup 0 1 2 lag_setup_network -test_bond_recovery mode 1 miimon 100 updelay 0 -test_bond_recovery mode 1 miimon 100 updelay 200 -test_bond_recovery mode 1 miimon 100 updelay 500 -test_bond_recovery mode 1 miimon 100 updelay 1000 -test_bond_recovery mode 1 miimon 100 updelay 2000 -test_bond_recovery mode 1 miimon 100 updelay 5000 -test_bond_recovery mode 1 miimon 100 updelay 10000 + +for mode in 1 2 3; do + for delay in 0 200 500 1000 2000 5000 10000; do + test_bond_recovery mode "${mode}" miimon 100 updelay "${delay}" + done +done exit "$EXIT_STATUS" -- 2.56.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 3/3] selftests: bonding: add recovery updelay test for broadcast mode 2026-12-01 6:29 ` [PATCH net v2 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu @ 2026-12-03 6:29 ` netdev-bot+sashiko 0 siblings, 0 replies; 9+ messages in thread From: netdev-bot+sashiko @ 2026-12-03 6:29 UTC (permalink / raw) To: hangbin.liu Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, tonghao, razor, shuah, jiangjiehua1, netdev, linux-kernel, linux-kselftest 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 mode-3 (broadcast) cases in recovery-updelay.sh cannot detect a regression of the fix in commit "bonding: update slave array… - [Low] The commit author identity 'Hangbin Liu <hangbin.liu@linux.dev>' has no matching Signed-off-by. -- selftests: bonding: add recovery updelay test for broadcast mode This commit adds broadcast mode (mode 3) to the bonding recovery updelay selftest. It merges the mode 1 and mode 2 scripts into a single recovery-updelay.sh, which loops over modes 1, 2 and 3 and a set of updelay values. > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> [Severity: Low] The Author: address (hangbin.liu@linux.dev) doesn't match the only Signed-off-by: address (liuhangbin@kylinos.cn). checkpatch reports this as FROM_SIGN_OFF_MISMATCH. The two earlier patches in the series have the same mismatch: "Revert "bonding: do not set usable_slaves for broadcast mode"" and "bonding: update slave array on link change for broadcast mode". Could the series be resent with a matching From:, or with an added Signed-off-by: for the author address? > diff --git a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/recovery-updelay.sh > similarity index 72% > rename from tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh > rename to tools/testing/selftests/drivers/net/bonding/recovery-updelay.sh > index 9d26ab4cad0b3..05edf9915cc0a 100755 > --- a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh > +++ b/tools/testing/selftests/drivers/net/bonding/recovery-updelay.sh > @@ -34,12 +34,11 @@ cleanup() > trap cleanup 0 1 2 > > lag_setup_network [ ... ] > + > +for mode in 1 2 3; do > + for delay in 0 200 500 1000 2000 5000 10000; do > + test_bond_recovery mode "${mode}" miimon 100 updelay "${delay}" > + done > +done [Severity: Low] Would the new mode 3 cases catch a regression of the follow-up fix "bonding: update slave array on link change for broadcast mode"? test_bond_recovery() in lag_lib.sh only checks ping before and after the flap: tools/testing/selftests/drivers/net/bonding/lag_lib.sh:test_bond_recovery() { ... ip netns exec ${SWITCH} ip link set eth0 down sleep 2 ip netns exec ${SWITCH} ip link set eth0 up ip netns exec ${SWITCH} ip link set eth1 down # re-verify connectivity slowwait 2 ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 -W 0.1 &> /dev/null ... } Without the follow-up commit, only bond_enslave() and __bond_release_one() rebuild the broadcast usable_slaves array. When updelay is non-zero, bond_enslave() puts a slave whose carrier is up into BOND_LINK_BACK. bond_update_slave_arr() skips slaves that fail bond_slave_can_tx(), so the array is built empty. For broadcast mode, bond_open(), bond_miimon_link_change() and the NETDEV_CHANGE handler do not rebuild the array. So bond_miimon_inspect() always takes this branch: drivers/net/bonding/bond_main.c:bond_miimon_inspect() { ... if (usable_slaves && usable_slaves->count == 0) ignore_updelay = true; ... } In that state, updelay is skipped even while a peer slave is still forwarding. The recovery step still succeeds at once, so every mode 3 case passes. So if someone removed the case the follow-up adds to bond_miimon_link_change(): case BOND_MODE_XOR: case BOND_MODE_BROADCAST: bond_update_slave_arr(bond, NULL); none of these cases would fail. The only state they seem to catch is a kernel without the revert, where usable_slaves is never published for broadcast. Separately, the updelay 0, 200, 500, 1000 and probably 2000 cases finish inside the roughly 2.3 second slowwait/ping window even when updelay is honoured. Only the 5000 and 10000 cases exercise the "ignore updelay when nothing is up" logic. Could the test also check that updelay still applies while another slave is up, for example by reading the slave link state or measuring timing? That would cover both directions described in the series. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-bond_broadcast_updelay-v2-0-969e1844f2c4%40kylinos.cn ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode 2026-12-01 6:29 [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu ` (2 preceding siblings ...) 2026-12-01 6:29 ` [PATCH net v2 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu @ 2026-12-01 6:34 ` netdev-bot+sinfo 2026-12-01 8:38 ` Hangbin Liu 3 siblings, 1 reply; 9+ messages in thread From: netdev-bot+sinfo @ 2026-12-01 6:34 UTC (permalink / raw) To: Hangbin Liu Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tonghao Zhang, Nikolay Aleksandrov, Shuah Khan, jiangjiehua (A), netdev, linux-kernel, linux-kselftest, stable Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode 2026-12-01 6:34 ` [PATCH net v2 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo @ 2026-12-01 8:38 ` Hangbin Liu 0 siblings, 0 replies; 9+ messages in thread From: Hangbin Liu @ 2026-12-01 8:38 UTC (permalink / raw) To: netdev-bot+sinfo Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tonghao Zhang, Nikolay Aleksandrov, Shuah Khan, jiangjiehua (A), netdev, linux-kernel, linux-kselftest, stable On Tue, Dec 01, 2026 at 06:34:43AM +0000, netdev-bot+sinfo@kernel.org wrote: > Hi! > > This is an automated message. This series looks like a fix, but its > commit messages seem to be missing some information: > > - How the issue was discovered, e.g. hit in production, hit during > development, syzbot report, manual code inspection, LLM or static > analysis tool scan. > > Please do not repost the series just to address the above. Instead, > reply to this email with the missing information, so that reviewers > can take it into account. > > *IMPORTANT*: If you do repost (for other reasons) - please include > the relevant info in the cover letter or commit messages. > -- > The evaluation is done by an LLM so it may be wrong, if you think > that is the case please reply and explain. The issue is found when I review JiangJiehua's patch. I will add this info (and Jiehua's test by) in cover-letter if there is a new version. Thanks Hangbin ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-03 6:29 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-01 6:29 [PATCH net v2 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu 2026-12-01 6:29 ` [PATCH net v2 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu 2026-12-03 6:29 ` netdev-bot+sashiko 2026-12-01 6:29 ` [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu 2026-12-03 6:29 ` netdev-bot+sashiko 2026-12-01 6:29 ` [PATCH net v2 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu 2026-12-03 6:29 ` netdev-bot+sashiko 2026-12-01 6:34 ` [PATCH net v2 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo 2026-12-01 8:38 ` Hangbin Liu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox