Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH net 0/3] bonding: ignore updelay when no active links for broadcast mode
@ 2026-11-26  2:30 Hangbin Liu
  2026-11-26  2:30 ` [PATCH net 1/3] Revert "bonding: do not set usable_slaves for broadcast mode" Hangbin Liu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ 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

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>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-26  7:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH net 3/3] selftests: bonding: add recovery updelay test " Hangbin Liu
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)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox