Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [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
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ 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] 5+ 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-01  6:29 ` [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu
  2026-12-01  6:34 ` [PATCH net v2 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo
  2 siblings, 0 replies; 5+ 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] 5+ 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-01  6:34 ` [PATCH net v2 0/3] bonding: ignore updelay when no active links " netdev-bot+sinfo
  2 siblings, 0 replies; 5+ 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] 5+ 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
  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:34 ` netdev-bot+sinfo
  2026-12-01  8:38   ` Hangbin Liu
  2 siblings, 1 reply; 5+ 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] 5+ 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; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2026-12-01  8:38 UTC | newest]

Thread overview: 5+ 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-01  6:29 ` [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode Hangbin Liu
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