* [PATCH net 1/3] Revert "bonding: do not set usable_slaves for broadcast mode"
2026-11-26 2:30 [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu
@ 2026-11-26 2:30 ` Hangbin Liu
2026-11-27 3:15 ` netdev-bot+sashiko
2026-11-26 2:30 ` [PATCH net 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-11-26 2:30 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>
This reverts commit 45fc134bcfadde456639c1b1e206e6918d69a553.
Commit 45fc134bcfad ("bonding: do not set usable_slaves for broadcast mode")
assumes the bond updelay always applies. However, per commit f8a65ab2f3ff
("bonding: fix link recovery in mode 2 when updelay is nonzero") and
section 13.1 paragraph 4 of the bonding documentation, 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 motivated 45fc134bcfad 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.
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] 10+ messages in thread* Re: [PATCH net 1/3] Revert "bonding: do not set usable_slaves for broadcast mode"
2026-11-26 2:30 ` [PATCH net 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu
@ 2026-11-27 3:15 ` netdev-bot+sashiko
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 3:15 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] Commit trailer and tagging problems on the revert.
- [Low] Comments no longer match how broadcast mode uses usable_slaves.
--
Revert "bonding: do not set usable_slaves for broadcast mode"
This reverts commit 45fc134bcfad. That commit stopped publishing
bond->usable_slaves in broadcast mode, so updelay was no longer ignored
when there were no active slaves. A follow-up patch in the series
rebuilds the slave array on link changes for broadcast mode.
> Revert "bonding: do not set usable_slaves for broadcast mode"
>
> This reverts commit 45fc134bcfadde456639c1b1e206e6918d69a553.
[ ... ]
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
[Severity: Low]
The From: address is Hangbin Liu <hangbin.liu@linux.dev>, but the
Signed-off-by: address is Hangbin Liu <liuhangbin@kylinos.cn>. Checkpatch
reports this as FROM_SIGN_OFF_MISMATCH. The other two patches in the series
have the same mismatch.
Should this revert carry a Fixes: tag, or a stable dependency note?
Commit 45fc134bcfad went in through net with its own Fixes: e0caeb24f538,
so it has probably reached stable. The follow-up "bonding: update slave
array on link change for broadcast mode" has Fixes: e0caeb24f538 and says
it needs this revert first. None of the tags tell stable tooling about
that ordering.
If only the follow-up is backported, it has no effect. The
bond_set_slave_arr() from 45fc134bcfad still drops usable_slaves for
broadcast mode.
If only this revert is backported, the bug that 45fc134bcfad fixed comes
back: in broadcast mode the stale, empty usable_slaves array makes the
bond always ignore updelay.
> 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);
> kfree_rcu(usable, rcu);
[Severity: Low]
This isn't a bug, but after this revert bond->usable_slaves is published
for BOND_MODE_BROADCAST too. Should the related comments in bond_main.c be
updated to match?
The comment above bond_update_slave_arr() still lists only the xmit-hash
modes:
drivers/net/bonding/bond_main.c:
/* 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 call site in bond_enslave() explains the broadcast case only in terms
of all_slaves:
/* broadcast mode uses the all_slaves to loop through slaves. */
if (bond_mode_can_use_xmit_hash(bond) ||
BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, NULL);
However, bond_miimon_inspect() now relies on the broadcast-mode
usable_slaves to decide ignore_updelay:
usable_slaves = rcu_dereference(bond->usable_slaves);
if (usable_slaves && usable_slaves->count == 0)
ignore_updelay = true;
The rest of the series does not change either comment. Neither comment
says that broadcast mode must keep usable_slaves current on link changes,
which the follow-up patch makes a requirement.
> +
> + 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/20261126-bond_broadcast_updelay-v1-0-188e5538d6ca%40kylinos.cn
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net 2/3] bonding: update slave array on link change for broadcast mode
2026-11-26 2:30 [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu
2026-11-26 2:30 ` [PATCH net 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu
@ 2026-11-26 2:30 ` Hangbin Liu
2026-11-27 3:15 ` netdev-bot+sashiko
2026-11-26 2:30 ` [PATCH net 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-11-26 2:30 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>
bond_miimon_link_change() rebuilds the slave array when a slave's
link state changes, but it has no broadcast case, so broadcast only
rebuilds usable_slaves on enslave/release. bond_miimon_inspect()
then derives ignore_updelay from a stale snapshot:
- if the last rebuild ran while no slave was can_tx (common for
batch enslave with updelay, since new slaves start in
BOND_LINK_BACK), the snapshot keeps count == 0 forever and
updelay is never honored, even once other slaves are usable;
- if the snapshot still lists a slave that has since gone down,
ignore_updelay stays false and updelay delays recovery even
when the bond has no usable links, contrary to section 13.1
paragraph 4 of the bonding documentation.
Add the broadcast case so the snapshot follows link transitions the
same way balance-xor does. This needs the revert of 45fc134bcfad as
a prerequisite: with 45fc134bcfad applied, bond_set_slave_arr()
discards the refreshed array for broadcast.
Fixes: e0caeb24f538 ("net: bonding: update the slave array for broadcast mode")
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
drivers/net/bonding/bond_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index d6675e87d06b..b1efbdf597ec 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;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net 2/3] bonding: update slave array on link change for broadcast mode
2026-11-26 2:30 ` [PATCH net 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu
@ 2026-11-27 3:15 ` netdev-bot+sashiko
2026-11-27 6:00 ` Hangbin Liu
0 siblings, 1 reply; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 3:15 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 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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] The commit message says the patch makes the broadcast
usable_slaves snapshot 'follow link transitions the same way balance-…
- [Medium] Because broadcast now publishes usable_slaves (the revert,
which this patch relies on), switching a broadcast bond to balance-rr…
- [Low] The series ordering is not bisect-safe, and the dependency
between the two patches is not recorded in tags.
--
bonding: update slave array on link change for broadcast mode
This adds a BOND_MODE_BROADCAST case to bond_miimon_link_change(), so the
usable_slaves snapshot is rebuilt on miimon link transitions. That keeps
the ignore_updelay decision in bond_miimon_inspect() in line with the
current slave link states. It depends on a revert of 45fc134bcfad so that
bond_set_slave_arr() publishes the array for broadcast.
> Add the broadcast case so the snapshot follows link transitions the
> same way balance-xor does. This needs the revert of 45fc134bcfad as
> a prerequisite: with 45fc134bcfad applied, bond_set_slave_arr()
> discards the refreshed array for broadcast.
>
> Fixes: e0caeb24f538 ("net: bonding: update the slave array for broadcast mode")
[Severity: Low]
Is the series order bisect-safe? The revert of 45fc134bcfad is applied
before this patch. On its own, it makes bond_set_slave_arr() publish
usable_slaves for broadcast again, but nothing rebuilds the array on
miimon link changes yet.
At that intermediate commit, a batch enslave with updelay leaves the new
slaves in BOND_LINK_BACK. The snapshot taken at enslave time then has
count == 0 and is never refreshed, so bond_miimon_inspect() ignores
updelay permanently. That is the bug 45fc134bcfad fixed.
If this patch went first, it would be a no-op under 45fc134bcfad, and
every commit in the series would be correct.
Also, this patch carries Fixes: e0caeb24f538, but the revert it depends on
has no Fixes: tag and no dependency annotation. 45fc134bcfad is likely
already in stable trees.
Would a tag-driven backport of only this patch leave the stale snapshot
behaviour unchanged there?
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index d6675e87d06b6..b1efbdf597ec4 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]
The commit message says the snapshot follows link transitions "the same
way balance-xor does". Does that hold outside the MII monitor?
balance-xor also rebuilds the array when the ARP load-balance monitor
changes a slave's link state. Broadcast is still left out there:
drivers/net/bonding/bond_main.c:bond_loadbalance_arp_mon() {
...
if (slave_state_changed) {
bond_slave_state_change(bond);
if (BOND_MODE(bond) == BOND_MODE_XOR)
bond_update_slave_arr(bond, NULL);
}
...
}
Broadcast can use ARP monitoring, because bond_mode_uses_arp() only
excludes BOND_MODE_8023AD, BOND_MODE_TLB and BOND_MODE_ALB.
bond_slave_netdev_event() also skips broadcast, since
bond_mode_can_use_xmit_hash() is false for it. So under ARP monitoring,
the broadcast snapshot keeps the state from the last enslave or release.
bond_option_miimon_set() can switch the bond from ARP monitoring to
miimon at runtime. It zeroes arp_interval, cancels arp_work and queues
mii_work, but it does not rebuild the slave array. params.updelay
survives the switch.
For example, slaves enslaved with carrier under ARP monitoring are marked
BOND_LINK_UP and counted in usable_slaves. Later the ARP monitor marks
them BOND_LINK_DOWN, but the snapshot is not refreshed. Once miimon is
enabled, bond_miimon_inspect() sees usable_slaves->count != 0:
if (usable_slaves && usable_slaves->count == 0)
ignore_updelay = true;
Recovering slaves then wait out updelay even though the bond has no usable
link.
The reverse case also happens. If slaves are enslaved without carrier,
count == 0 and updelay is wrongly ignored. Either state lasts until the
first miimon commit reaches bond_miimon_link_change().
Should BOND_MODE_BROADCAST also be added to the condition in
bond_loadbalance_arp_mon()?
[Severity: Medium]
Now that broadcast publishes usable_slaves, does a switch from broadcast
to balance-rr leave a stale snapshot behind?
Releasing the last broadcast slave goes through __bond_release_one():
if (bond_mode_can_use_xmit_hash(bond) ||
BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, slave);
This runs after bond_upper_dev_unlink(), so the slave list is already
empty. The result is a non-NULL usable_slaves with count == 0, and after
the revert that array is kept for broadcast.
Neither bond_option_mode_set() nor bond_close() resets the arrays.
In balance-rr, nothing rebuilds the array afterwards:
- bond_enslave() and __bond_release_one() only rebuild for xmit-hash
modes or broadcast
- bond_open() and bond_slave_netdev_event() only rebuild when
bond_mode_can_use_xmit_hash() is true
- bond_miimon_link_change() has no BOND_MODE_ROUNDROBIN case
So in balance-rr, bond_miimon_inspect() would see count == 0 on every
pass. It would set ignore_updelay = true and force slave->delay to 0 for
every recovering slave.
Documentation/networking/bonding.rst section 13.1 says updelay is ignored
only when the bond has no active links.
In the baseline tree with 45fc134bcfad, broadcast never published
usable_slaves, so a switch from broadcast to balance-rr left it NULL. The
same missing reset on mode change already existed for a switch from
balance-xor to balance-rr.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-bond_broadcast_updelay-v1-0-188e5538d6ca%40kylinos.cn
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net 2/3] bonding: update slave array on link change for broadcast mode
2026-11-27 3:15 ` netdev-bot+sashiko
@ 2026-11-27 6:00 ` Hangbin Liu
0 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-27 6:00 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, tonghao, razor,
shuah, jiangjiehua1, netdev, linux-kernel, linux-kselftest
On Fri, Nov 27, 2026 at 03:15:57AM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 2 · 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] The commit message says the patch makes the broadcast
> usable_slaves snapshot 'follow link transitions the same way balance-…
> - [Medium] Because broadcast now publishes usable_slaves (the revert,
> which this patch relies on), switching a broadcast bond to balance-rr…
> - [Low] The series ordering is not bisect-safe, and the dependency
> between the two patches is not recorded in tags.
>
> --
>
> bonding: update slave array on link change for broadcast mode
>
> This adds a BOND_MODE_BROADCAST case to bond_miimon_link_change(), so the
> usable_slaves snapshot is rebuilt on miimon link transitions. That keeps
> the ignore_updelay decision in bond_miimon_inspect() in line with the
> current slave link states. It depends on a revert of 45fc134bcfad so that
> bond_set_slave_arr() publishes the array for broadcast.
>
> > Add the broadcast case so the snapshot follows link transitions the
> > same way balance-xor does. This needs the revert of 45fc134bcfad as
> > a prerequisite: with 45fc134bcfad applied, bond_set_slave_arr()
> > discards the refreshed array for broadcast.
> >
> > Fixes: e0caeb24f538 ("net: bonding: update the slave array for broadcast mode")
>
> [Severity: Low]
> Is the series order bisect-safe? The revert of 45fc134bcfad is applied
> before this patch. On its own, it makes bond_set_slave_arr() publish
> usable_slaves for broadcast again, but nothing rebuilds the array on
> miimon link changes yet.
>
> At that intermediate commit, a batch enslave with updelay leaves the new
> slaves in BOND_LINK_BACK. The snapshot taken at enslave time then has
> count == 0 and is never refreshed, so bond_miimon_inspect() ignores
> updelay permanently. That is the bug 45fc134bcfad fixed.
>
> If this patch went first, it would be a no-op under 45fc134bcfad, and
> every commit in the series would be correct.
>
> Also, this patch carries Fixes: e0caeb24f538, but the revert it depends on
> has no Fixes: tag and no dependency annotation. 45fc134bcfad is likely
> already in stable trees.
>
> Would a tag-driven backport of only this patch leave the stale snapshot
> behaviour unchanged there?
This commit description already said it depends on the revert.
>
> > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> > index d6675e87d06b6..b1efbdf597ec4 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]
> The commit message says the snapshot follows link transitions "the same
> way balance-xor does". Does that hold outside the MII monitor?
>
> balance-xor also rebuilds the array when the ARP load-balance monitor
> changes a slave's link state. Broadcast is still left out there:
>
> drivers/net/bonding/bond_main.c:bond_loadbalance_arp_mon() {
> ...
> if (slave_state_changed) {
> bond_slave_state_change(bond);
> if (BOND_MODE(bond) == BOND_MODE_XOR)
> bond_update_slave_arr(bond, NULL);
> }
> ...
> }
>
> Broadcast can use ARP monitoring, because bond_mode_uses_arp() only
> excludes BOND_MODE_8023AD, BOND_MODE_TLB and BOND_MODE_ALB.
> bond_slave_netdev_event() also skips broadcast, since
> bond_mode_can_use_xmit_hash() is false for it. So under ARP monitoring,
> the broadcast snapshot keeps the state from the last enslave or release.
>
> bond_option_miimon_set() can switch the bond from ARP monitoring to
> miimon at runtime. It zeroes arp_interval, cancels arp_work and queues
> mii_work, but it does not rebuild the slave array. params.updelay
> survives the switch.
>
> For example, slaves enslaved with carrier under ARP monitoring are marked
> BOND_LINK_UP and counted in usable_slaves. Later the ARP monitor marks
> them BOND_LINK_DOWN, but the snapshot is not refreshed. Once miimon is
> enabled, bond_miimon_inspect() sees usable_slaves->count != 0:
>
> if (usable_slaves && usable_slaves->count == 0)
> ignore_updelay = true;
>
> Recovering slaves then wait out updelay even though the bond has no usable
> link.
>
> The reverse case also happens. If slaves are enslaved without carrier,
> count == 0 and updelay is wrongly ignored. Either state lasts until the
> first miimon commit reaches bond_miimon_link_change().
>
> Should BOND_MODE_BROADCAST also be added to the condition in
> bond_loadbalance_arp_mon()?
Ack, I will also handle the arp monitor.
>
> [Severity: Medium]
> Now that broadcast publishes usable_slaves, does a switch from broadcast
> to balance-rr leave a stale snapshot behind?
>
> Releasing the last broadcast slave goes through __bond_release_one():
>
> if (bond_mode_can_use_xmit_hash(bond) ||
> BOND_MODE(bond) == BOND_MODE_BROADCAST)
> bond_update_slave_arr(bond, slave);
>
> This runs after bond_upper_dev_unlink(), so the slave list is already
> empty. The result is a non-NULL usable_slaves with count == 0, and after
> the revert that array is kept for broadcast.
>
> Neither bond_option_mode_set() nor bond_close() resets the arrays.
>
> In balance-rr, nothing rebuilds the array afterwards:
>
> - bond_enslave() and __bond_release_one() only rebuild for xmit-hash
> modes or broadcast
> - bond_open() and bond_slave_netdev_event() only rebuild when
> bond_mode_can_use_xmit_hash() is true
> - bond_miimon_link_change() has no BOND_MODE_ROUNDROBIN case
>
> So in balance-rr, bond_miimon_inspect() would see count == 0 on every
> pass. It would set ignore_updelay = true and force slave->delay to 0 for
> every recovering slave.
>
> Documentation/networking/bonding.rst section 13.1 says updelay is ignored
> only when the bond has no active links.
>
> In the baseline tree with 45fc134bcfad, broadcast never published
> usable_slaves, so a switch from broadcast to balance-rr left it NULL. The
> same missing reset on mode change already existed for a switch from
> balance-xor to balance-rr.
This seems not broadcast only issue. The other xmit hash mode also have this
problem. Maybe we should set usable_array to NULL if it's length is 0? Need
to further checking.
Thanks
Hangbin
---
pw-bot: cr
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net 3/3] selftests: bonding: add recovery updelay test for broadcast mode
2026-11-26 2:30 [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu
2026-11-26 2:30 ` [PATCH net 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu
2026-11-26 2:30 ` [PATCH net 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu
@ 2026-11-26 2:30 ` Hangbin Liu
2026-11-27 3:15 ` netdev-bot+sashiko
2026-11-26 2:32 ` [PATCH net 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo
2026-11-26 7:28 ` jiangjiehua (A)
4 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-11-26 2:30 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] 10+ messages in thread* Re: [PATCH net 3/3] selftests: bonding: add recovery updelay test for broadcast mode
2026-11-26 2:30 ` [PATCH net 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu
@ 2026-11-27 3:15 ` netdev-bot+sashiko
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 3:15 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 cases in recovery-updelay.sh pass whether or not
the companion fix "bonding: update slave array on link change for…
- [Low] The commit author is "Hangbin Liu <hangbin.liu@linux.dev>", but
the only Signed-off-by is "Hangbin Liu <liuhangbin@kylinos.cn>".
--
selftests: bonding: add recovery updelay test for broadcast mode
This merges the mode 1 and mode 2 recovery updelay selftests into one
recovery-updelay.sh script. The script now also covers bonding mode 3
(broadcast), and the Makefile installs the merged script.
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
[Severity: Low]
The Author: line is "Hangbin Liu <hangbin.liu@linux.dev>", but the only
Signed-off-by is "Hangbin Liu <liuhangbin@kylinos.cn>". Won't checkpatch.pl
report this as a From:/Signed-off-by: email mismatch?
Could a From: line that matches the sign-off identity be added to the body?
Adding a sign-off from the author address would also work. The other two
patches in the series appear to have the same mismatch.
[ ... ]
> 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]
Do the new mode 3 cases pass whether or not the companion fix "bonding:
update slave array on link change for broadcast mode" is applied?
After the flap, test_bond_recovery() in lag_lib.sh only checks that ping
works again:
tools/testing/selftests/drivers/net/bonding/lag_lib.sh:test_bond_recovery() {
...
slowwait 2 ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 -W 0.1 &> /dev/null
...
}
That covers the case where no slave is usable, so updelay is ignored. The
companion fix handles the opposite case. There, a stale usable_slaves
snapshot with count == 0 makes bond_miimon_inspect() set ignore_updelay
on every pass:
drivers/net/bonding/bond_main.c:bond_miimon_inspect() {
...
if (usable_slaves && usable_slaves->count == 0)
ignore_updelay = true;
...
}
Without the fix, this is what happens:
- create_bond() enslaves eth0 and eth1 with updelay > 0.
- bond_enslave() puts both slaves in BOND_LINK_BACK.
- bond_update_slave_arr() builds usable_slaves with count == 0, because
bond_slave_can_tx() requires BOND_LINK_UP.
In broadcast mode nothing rebuilds that array on link change.
bond_miimon_link_change() has no BOND_MODE_BROADCAST case. The rebuilds in
bond_open() and the NETDEV_CHANGE handler only run when
bond_mode_can_use_xmit_hash() is true. So recovery is always immediate,
and the test still passes.
Could a case be added that checks a slave still waits out updelay while
another slave is usable? Without one, the companion fix has no test
coverage. The revert patch says the two patches together "keep
ignore_updelay correct in both directions", but only one direction is
tested.
Also, slowwait waits 2 seconds, so the delays from 0 to 1000 ms appear to
pass even with 45fc134bcfad still applied. Only the 2000 (borderline), 5000
and 10000 ms cases seem to tell the two behaviours apart.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-bond_broadcast_updelay-v1-0-188e5538d6ca%40kylinos.cn
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode
2026-11-26 2:30 [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu
` (2 preceding siblings ...)
2026-11-26 2:30 ` [PATCH net 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu
@ 2026-11-26 2:32 ` netdev-bot+sinfo
2026-11-26 7:28 ` jiangjiehua (A)
4 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sinfo @ 2026-11-26 2:32 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
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] 10+ messages in thread* Re: [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode
2026-11-26 2:30 [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode Hangbin Liu
` (3 preceding siblings ...)
2026-11-26 2:32 ` [PATCH net 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo
@ 2026-11-26 7:28 ` jiangjiehua (A)
4 siblings, 0 replies; 10+ messages in thread
From: jiangjiehua (A) @ 2026-11-26 7:28 UTC (permalink / raw)
To: Hangbin Liu, Jay Vosburgh, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tonghao Zhang,
Nikolay Aleksandrov, Shuah Khan
Cc: netdev, linux-kernel, linux-kselftest
Hi Hangbin,
On 11/26/2026 10:30 AM, Hangbin Liu wrote:
> 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>
> ---
> 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 | 14 +++----
> .../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, 12 insertions(+), 63 deletions(-)
> ---
> base-commit: 1ab3fb564f20b78615a6d88b8c90da292f29e227
> change-id: 20261126-bond_broadcast_updelay-cc4cfb6e0e37
>
> Best regards,
> --
> Hangbin Liu <liuhangbin@kylinos.cn>
Tested on v7.4-rc4 in a virtme-ng guest. Ran recovery-updelay.sh (21/21
OK) and the cover-letter Test A/B; both match the expected updelay behavior.
Tested-by: JiangJieHua <jiangjiehua1@huawei.com>
Thanks,
Jiehua
^ permalink raw reply [flat|nested] 10+ messages in thread