bonding: fix the initial last_rx seed for the ARP monitor
Subsystems (3)
v5 cover bonding: fix the initial last_rx seed for the ARP monitor
bond_enslave() seeds a new slave's last_rx before it has received anything. The ARP monitor checks that seed with an up test for a slave that starts DOWN, and with a down test for a slave that starts UP. The seed is wrong for both.
Patch 1 fixes a slave that starts DOWN. Since the up test gained arp_interval/2 of slack, the seed falls inside the up window, so the slave is reported UP for half an interval without having received anything.
Patch 2 fixes a slave that starts UP. The seed brings its down deadline forward by one interval compared to what arp_missed_max implies. In load-balance mode, which has no grace period after enslavement, a healthy slave can flap DOWN with arp_missed_max=1.
Both patches only cover a slave enslaved while the ARP monitor is running. The seed is not refreshed when the monitor starts later, from bond_open() or when arp_interval is set at runtime. That predates this series, I will address it in a separate follow-up.
---
Changes in v5:
- Patch 1: set last_link_up in the UP branch of the seed (Hangbin).
- Patch 1: say "until it receives traffic" instead of "until a real
reply arrives", any frame updates last_rx with arp_validate=none
(Sashiko).
- Patch 2: say that it only covers a slave enslaved while the ARP
monitor is running (Sashiko).
- Pick up Hangbin's Reviewed-by on patch 1.
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
- Patch 1: only use the older seed for a slave that starts DOWN. v3
also applied it to a slave that starts UP, which brought its down
deadline forward by one interval (Jay).
- New patch 2: seed a slave that starts UP with last_link_up, giving it
a full arp_missed_max window. Fixes an existing flap in load-balance
mode with arp_missed_max=1.
- Drop Hangbin's Reviewed-by, patch 1 changed.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- No code changes. Rebase on current net.
- Reword the commit message along the lines of the v2 discussion: lead
with what the last_rx seed is for, state that the false UP happens
independent of primary_reselect, and that the initial link state is
unchanged.
- Pick up Reviewed-by from Hangbin.
- Cc Nikolay. Hangbin asked for a second review, Jay or Nikolay, would
you have a look?
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- No code changes. Resend with my personal name in the From and
Signed-off-by lines instead of my handle, as requested for the DCO.
- Link to v1: https://patch.msgid.link/[email protected]
---
Ramses de Norre (2):
bonding: fix initial last_rx vs ARP-monitor slack window
bonding: give a slave that starts UP a full arp_missed_max window
drivers/net/bonding/bond_main.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
---
base-commit: f75062536e2d45ee182828f0e47e0124be2fdc8d
change-id: 20260817-bonding-last-rx-0303fa048f9d
Best regards,
Signature · 1 line
Ramses de Norre <[email protected]>
PATCH v5 1/2 bonding: fix initial last_rx vs ARP-monitor slack window
bond_enslave() seeds a new slave's last_rx so that the ARP monitor does not report it UP before it receives traffic, see commit f31c7937c254 ("bonding: start slaves with link down for ARP monitor").
The seed is one arp_interval (plus a tick) in the past. That was old enough when the up test was "jiffies <= last_rx + arp_interval". Commit da210f559019 ("bonding: add some slack to arp monitoring time limits") added arp_interval/2 of slack to that test without moving the seed, so the seed now falls inside the up window. For the first half interval after enslavement, bond_ab_arp_inspect() proposes a slave that starts DOWN as UP although it has received nothing. The up test always uses a single interval, so this does not depend on primary_reselect or arp_missed_max.
If that slave is the configured primary, force_primary makes it the active slave. ARP validation fails it shortly after (on SFP+ ports the PHY is often still negotiating) and the bond falls back to the backup. With primary_reselect=always the bond recovers once the port really comes up, but drops traffic until then. With primary_reselect=failure, force_primary is spent and the bond stays on the backup.
Reproducer:
ip link add bond0 type bond mode active-backup arp_interval 1000 \
arp_validate all arp_ip_target 192.0.2.1 \
primary eth0 primary_reselect failure
# eth0: SFP+ (slow link-up), eth1: RJ45 (fast link-up)
ip link set eth0 master bond0
ip link set eth1 master bond0
ip link set bond0 up
# bond0 lands on eth0 via force_primary, ARP-fails it before the
# SFP+ has carrier, falls to eth1, and stays there.Move the seed below the initial link state and seed a slave that starts DOWN two intervals in the past, outside the up window. A slave that starts UP keeps its current seed: the up test does not apply to it, and an older seed would only bring its down deadline forward by one interval. The initial link state is unchanged.
--- drivers/net/bonding/bond_main.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/bonding/bond_main.c +16 -8
@@ -2122,13 +2122,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,if (res &&bond_needs_speed_duplex (bond)) new_slave->link =BOND_LINK_DOWN ; - new_slave->last_rx = jiffies - - (msecs_to_jiffies (bond->params.arp_interval) +1 ); -for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) - new_slave->target_last_arp_rx[i] = new_slave->last_rx; - - new_slave->last_tx = new_slave->last_rx; -/* check for initial state */ new_slave->link =BOND_LINK_NOCHANGE ;if (bond->params.miimon) {
@@ -2157,8 +2150,23 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, BOND_SLAVE_NOTIFY_NOW); } -if (new_slave->link !=BOND_LINK_DOWN ) +/* The ARP monitor's up test includes arp_interval/2 of slack, see +* bond_time_in_interval(). Seed a slave that starts DOWN outside +* that window, so it stays DOWN until it receives traffic. +*/ +if (new_slave->link ==BOND_LINK_DOWN ) { + new_slave->last_rx = jiffies - + (2 *msecs_to_jiffies (bond->params.arp_interval) +1 ); + }else { new_slave->last_link_up = jiffies; + new_slave->last_rx = jiffies - + (msecs_to_jiffies (bond->params.arp_interval) +1 ); + } +for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) + new_slave->target_last_arp_rx[i] = new_slave->last_rx; + + new_slave->last_tx = new_slave->last_rx; +slave_dbg (bond_dev, slave_dev,"Initial state of slave is BOND_LINK_%s\n" , new_slave->link ==BOND_LINK_DOWN ?"DOWN" : (new_slave->link ==BOND_LINK_UP ?"UP" :"BACK" ));
Signature · 1 line
2.56.0
PATCH v5 2/2 bonding: give a slave that starts UP a full arp_missed_max window
In reply to Ramses de NorreThe ARP monitor marks an UP slave DOWN once jiffies passes last_rx + arp_missed_max * arp_interval + arp_interval/2. bond_enslave() seeds last_rx one arp_interval (plus a tick) in the past, which brings the down deadline of a slave that starts UP forward by one interval compared to what arp_missed_max promises.
Active-backup mode hides this with a grace period after enslavement in bond_ab_arp_inspect(). Load-balance mode has no grace period after enslavement. With arp_missed_max=1 the deadline is half an interval after enslavement, and the first monitor run checks the slave before it sends the first probe. If that run lands in the second half of the interval, a healthy slave is reported "interface is now down" and comes back UP on the next run.
Seed a slave that starts UP with last_link_up instead, so it gets a full arp_missed_max window for its first reply. bond_arp_rcv() and bond_na_rcv() only trust ARPs seen on backup slaves once the active slave's last_rx is after its last_link_up. A seed equal to last_link_up keeps that check false until a real reply arrives, as it is today.
This only covers a slave enslaved while the ARP monitor is running. When the monitor starts later, from bond_open() or when arp_interval is set at runtime, the seed is still as old as the time since enslavement, as it was before this patch.
--- drivers/net/bonding/bond_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +6 -2
@@ -2158,9 +2158,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, new_slave->last_rx = jiffies - (2 *msecs_to_jiffies (bond->params.arp_interval) +1 ); }else { +/* Give a slave that starts UP a full arp_missed_max window. +* Not seeding it later than last_link_up keeps bond_arp_rcv() +* from trusting ARPs on backup slaves before the active one +* got a reply. +*/ new_slave->last_link_up = jiffies; - new_slave->last_rx = jiffies - - (msecs_to_jiffies (bond->params.arp_interval) +1 ); + new_slave->last_rx = new_slave->last_link_up; }for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) new_slave->target_last_arp_rx[i] = new_slave->last_rx;
Signature · 1 line
2.56.0
Paolo Abeni
maintainerRe: [PATCH net v5 2/2] bonding: give a slave that starts UP a full arp_missed_max window
Quoted 42 lines · Ramses de Norre
The ARP monitor marks an UP slave DOWN once jiffies passes
last_rx+arp_missed_max*arp_interval+ arp_interval/2.bond_enslave()seedslast_rxonearp_interval(plus a tick) in the past, which brings the down deadline of a slave that starts UP forward by one interval compared to whatarp_missed_maxpromises.Active-backup mode hides this with a grace period after enslavement in
bond_ab_arp_inspect(). Load-balance mode has no grace period after enslavement. With arp_missed_max=1 the deadline is half an interval after enslavement, and the first monitor run checks the slave before it sends the first probe. If that run lands in the second half of the interval, a healthy slave is reported "interface is now down" and comes back UP on the next run.Seed a slave that starts UP with
last_link_upinstead, so it gets a fullarp_missed_maxwindow for its first reply.bond_arp_rcv()andbond_na_rcv()only trust ARPs seen on backup slaves once the active slave'slast_rxis after itslast_link_up. A seed equal tolast_link_upkeeps that check false until a real reply arrives, as it is today.This only covers a slave enslaved while the ARP monitor is running. When the monitor starts later, from
bond_open()or whenarp_intervalis set at runtime, the seed is still as old as the time since enslavement, as it was before this patch.Fixes 5944b5abd864 ("Bonding: add arp_missed_max option")Signed-off-by Ramses de Norre <[email protected]>--- drivers/net/bonding/bond_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +2
-0@@ -2158,9 +2158,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, new_slave->last_rx = jiffies - (2 *msecs_to_jiffies (bond->params.arp_interval) +1 ); }else { +/* Give a slave that starts UP a full arp_missed_max window. +* Not seeding it later than last_link_up keeps bond_arp_rcv()
drivers/net/bonding/bond_main.c int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, · line 2170
Quoted 10 lines
drivers/net/bonding/bond_main.c +4
-2+* from trusting ARPs on backup slaves before the active one +* got a reply. +*/ new_slave->last_link_up = jiffies; - new_slave->last_rx = jiffies - - (msecs_to_jiffies (bond->params.arp_interval) +1 ); + new_slave->last_rx = new_slave->last_link_up; }for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) new_slave->target_last_arp_rx[i] = new_slave->last_rx;
@Jay, @Hangbin: can you please have a look here?
Thanks!
Paolo
Re: [PATCH net v5 2/2] bonding: give a slave that starts UP a full arp_missed_max window
Quoted 47 lines · Paolo Abeni
Quoted 46 lines · Ramses de Norre
The ARP monitor marks an UP slave DOWN once jiffies passes
last_rx+arp_missed_max*arp_interval+ arp_interval/2.bond_enslave()seedslast_rxonearp_interval(plus a tick) in the past, which brings the down deadline of a slave that starts UP forward by one interval compared to whatarp_missed_maxpromises.Active-backup mode hides this with a grace period after enslavement in
bond_ab_arp_inspect(). Load-balance mode has no grace period after enslavement. With arp_missed_max=1 the deadline is half an interval after enslavement, and the first monitor run checks the slave before it sends the first probe. If that run lands in the second half of the interval, a healthy slave is reported "interface is now down" and comes back UP on the next run.Seed a slave that starts UP with
last_link_upinstead, so it gets a fullarp_missed_maxwindow for its first reply.bond_arp_rcv()andbond_na_rcv()only trust ARPs seen on backup slaves once the active slave'slast_rxis after itslast_link_up. A seed equal tolast_link_upkeeps that check false until a real reply arrives, as it is today.This only covers a slave enslaved while the ARP monitor is running. When the monitor starts later, from
bond_open()or whenarp_intervalis set at runtime, the seed is still as old as the time since enslavement, as it was before this patch.Fixes 5944b5abd864 ("Bonding: add arp_missed_max option")Signed-off-by Ramses de Norre <[email protected]>--- drivers/net/bonding/bond_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +5
-1@@ -2158,9 +2158,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, new_slave->last_rx = jiffies - (2 *msecs_to_jiffies (bond->params.arp_interval) +1 ); }else { +/* Give a slave that starts UP a full arp_missed_max window. +* Not seeding it later than last_link_up keeps bond_arp_rcv() +* from trusting ARPs on backup slaves before the active one +* got a reply. +*/ new_slave->last_link_up = jiffies; - new_slave->last_rx = jiffies -
Quoted 8 lines
drivers/net/bonding/bond_main.c int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, · line 2170
Quoted 6 lines
drivers/net/bonding/bond_main.c +1
-1- (msecs_to_jiffies (bond->params.arp_interval) +1 ); + new_slave->last_rx = new_slave->last_link_up; }for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) new_slave->target_last_arp_rx[i] = new_slave->last_rx;@Jay, @Hangbin: can you please have a look here?
Yes, I’ve read this patchset a few times but haven’t thought through it carefully, since the ARP inspection logic is a bit complex. I’ll try to finish the review today.
Thanks
Hangbin
Re: [PATCH net v5 2/2] bonding: give a slave that starts UP a full arp_missed_max window
In reply to Ramses de NorreQuoted 58 lines · On Fri, Oct 30, 2026 at 03:51:16PM +0100, Ramses de Norre via B4 Relay wrote:
From: Ramses de Norre <[email protected]>
The ARP monitor marks an UP slave DOWN once jiffies passes
last_rx+arp_missed_max*arp_interval+ arp_interval/2.bond_enslave()seedslast_rxonearp_interval(plus a tick) in the past, which brings the down deadline of a slave that starts UP forward by one interval compared to whatarp_missed_maxpromises.Active-backup mode hides this with a grace period after enslavement in
bond_ab_arp_inspect(). Load-balance mode has no grace period after enslavement. With arp_missed_max=1 the deadline is half an interval after enslavement, and the first monitor run checks the slave before it sends the first probe. If that run lands in the second half of the interval, a healthy slave is reported "interface is now down" and comes back UP on the next run.Seed a slave that starts UP with
last_link_upinstead, so it gets a fullarp_missed_maxwindow for its first reply.bond_arp_rcv()andbond_na_rcv()only trust ARPs seen on backup slaves once the active slave'slast_rxis after itslast_link_up. A seed equal tolast_link_upkeeps that check false until a real reply arrives, as it is today.This only covers a slave enslaved while the ARP monitor is running. When the monitor starts later, from
bond_open()or whenarp_intervalis set at runtime, the seed is still as old as the time since enslavement, as it was before this patch.Fixes 5944b5abd864 ("Bonding: add arp_missed_max option")Signed-off-by Ramses de Norre <[email protected]>--- drivers/net/bonding/bond_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +6
-2@@ -2158,9 +2158,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, new_slave->last_rx = jiffies - (2 *msecs_to_jiffies (bond->params.arp_interval) +1 ); }else { +/* Give a slave that starts UP a full arp_missed_max window. +* Not seeding it later than last_link_up keeps bond_arp_rcv() +* from trusting ARPs on backup slaves before the active one +* got a reply. +*/ new_slave->last_link_up = jiffies; - new_slave->last_rx = jiffies - - (msecs_to_jiffies (bond->params.arp_interval) +1 ); + new_slave->last_rx = new_slave->last_link_up; }for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) new_slave->target_last_arp_rx[i] = new_slave->last_rx;Signature · 2 lines
-- 2.56.0
Sashiko reported some other issues during arp_target/arp_interval set. But none of these introduced by this patch. And we haven't received real user report about these issues.
So for this patch
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Fri, 30 Oct 2026 15:51:14 +0100 you wrote:
bond_enslave()seeds a new slave'slast_rxbefore it has received anything. The ARP monitor checks that seed with an up test for a slave that starts DOWN, and with a down test for a slave that starts UP. The seed is wrong for both.Patch 1 fixes a slave that starts DOWN. Since the up test gained arp_interval/2 of slack, the seed falls inside the up window, so the slave is reported UP for half an interval without having received anything.
[...]
Here is the summary with links:
- [net,v5,1/2] bonding: fix initial last_rx vs ARP-monitor slack window
https://git.kernel.org/netdev/net-next/c/7cf2286b280b - [net,v5,2/2] bonding: give a slave that starts UP a full arp_missed_max window https://git.kernel.org/netdev/net-next/c/9231c2b6f180
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html