* [PATCH net-next 0/2] bonding: reseed the ARP monitor when it starts
@ 2026-12-01 10:20 Ramses de Norre via B4 Relay
2026-12-01 10:20 ` [PATCH net-next 1/2] " Ramses de Norre via B4 Relay
2026-12-01 10:20 ` [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves " Ramses de Norre via B4 Relay
0 siblings, 2 replies; 7+ messages in thread
From: Ramses de Norre via B4 Relay @ 2026-12-01 10:20 UTC (permalink / raw)
To: Jay Vosburgh, Andrew Lunn, David S. Miller, Jakub Kicinski,
Paolo Abeni, Jiri Bohac, Eric Dumazet, Willem de Bruijn,
Simon Horman
Cc: netdev, linux-kernel, linux-kselftest, Nikolay Aleksandrov,
Hangbin Liu, Shuah Khan, Ramses de Norre
bond_enslave() seeds the ARP monitor timestamps of a new slave. When the
monitor starts later, from bond_open() or when arp_interval is set on a
bond that uses miimon, those seeds are as old as the time since
enslavement. The first monitor run then takes the UP slaves down before
a single probe went out.
This is the follow-up I mentioned in the v5 cover letter of the last_rx
series, which is now in net-next.
Patch 1 reseeds the slaves when the monitor starts.
Patch 2 adds a selftest for both start paths. It fails without patch 1
and passes with it.
Link: https://lore.kernel.org/netdev/20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev/
Signed-off-by: Ramses de Norre <ramses@well-founded.dev>
---
Ramses de Norre (2):
bonding: reseed the ARP monitor when it starts
selftests: bonding: test that the ARP monitor keeps UP slaves when it starts
drivers/net/bonding/bond_main.c | 58 +++++---
drivers/net/bonding/bond_options.c | 6 +-
include/net/bonding.h | 1 +
.../testing/selftests/drivers/net/bonding/Makefile | 1 +
.../drivers/net/bonding/bond_arp_monitor_start.sh | 154 +++++++++++++++++++++
5 files changed, 198 insertions(+), 22 deletions(-)
---
base-commit: 02e8a63b4685a4321c60d562edabecc097f4a0d9
change-id: 20261201-bonding-arp-reseed-c24c7b5f99f3
Best regards,
--
Ramses de Norre <ramses@well-founded.dev>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next 1/2] bonding: reseed the ARP monitor when it starts 2026-12-01 10:20 [PATCH net-next 0/2] bonding: reseed the ARP monitor when it starts Ramses de Norre via B4 Relay @ 2026-12-01 10:20 ` Ramses de Norre via B4 Relay 2026-12-03 3:18 ` Hangbin Liu 2026-12-03 3:34 ` netdev-bot+sashiko 2026-12-01 10:20 ` [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves " Ramses de Norre via B4 Relay 1 sibling, 2 replies; 7+ messages in thread From: Ramses de Norre via B4 Relay @ 2026-12-01 10:20 UTC (permalink / raw) To: Jay Vosburgh, Andrew Lunn, David S. Miller, Jakub Kicinski, Paolo Abeni, Jiri Bohac, Eric Dumazet, Willem de Bruijn, Simon Horman Cc: netdev, linux-kernel, linux-kselftest, Nikolay Aleksandrov, Hangbin Liu, Shuah Khan, Ramses de Norre From: Ramses de Norre <ramses@well-founded.dev> When a slave is enslaved while the bond is down, the ARP monitor only starts when the bond is brought up. When it is enslaved while the bond uses miimon, the ARP monitor only starts when an arp_interval is set. In both cases the monitor sees the timestamps that were seeded at enslave time, which can be arbitrarily old. The first monitor run then marks the UP slaves down before a single probe went out, and the bond comes back on whichever slave answers first. With primary_reselect=failure it can stay on the backup. systemd-networkd hits this with a bond that is brought up separately, for example with ActivationPolicy=manual. The fix is to reseed the slaves when the ARP monitor starts. Link: https://lore.kernel.org/netdev/20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev/ Signed-off-by: Ramses de Norre <ramses@well-founded.dev> --- drivers/net/bonding/bond_main.c | 58 ++++++++++++++++++++++++-------------- drivers/net/bonding/bond_options.c | 6 +++- include/net/bonding.h | 1 + 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 754048ef4835d..a015f20e0718e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1888,6 +1888,40 @@ void bond_xdp_set_features(struct net_device *bond_dev) xdp_set_features_flag(bond_dev, val); } +/* Seed a slave that is not UP outside the up window. Give a slave that is + * UP a full arp_missed_max window. + */ +static void bond_arp_seed_slave(struct bonding *bond, struct slave *slave) +{ + unsigned long seed; + int i; + + if (slave->link == BOND_LINK_UP) { + slave->last_link_up = jiffies; + seed = slave->last_link_up; + } else { + seed = jiffies - + (2 * msecs_to_jiffies(bond->params.arp_interval) + 1); + } + + WRITE_ONCE(slave->last_rx, seed); + for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) + WRITE_ONCE(slave->target_last_arp_rx[i], seed); + WRITE_ONCE(slave->last_tx, seed); +} + +/* Call before recv_probe is set and arp_work is queued. */ +void bond_arp_reseed_slaves(struct bonding *bond) +{ + struct list_head *iter; + struct slave *slave; + + ASSERT_RTNL(); + + bond_for_each_slave(bond, slave, iter) + bond_arp_seed_slave(bond, slave); +} + /* enslave device <slave> to bond device <master> */ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, struct netlink_ext_ack *extack) @@ -1896,7 +1930,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, const struct net_device_ops *slave_ops = slave_dev->netdev_ops; struct slave *new_slave = NULL, *prev_slave; struct sockaddr_storage ss; - int res = 0, i; + int res = 0; if (slave_dev->type == ARPHRD_CAN || slave_dev->type == ARPHRD_IEEE802154 || @@ -2158,26 +2192,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, BOND_SLAVE_NOTIFY_NOW); } - /* 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 { - /* 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 = 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; - - new_slave->last_tx = new_slave->last_rx; + bond_arp_seed_slave(bond, new_slave); slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", new_slave->link == BOND_LINK_DOWN ? "DOWN" : @@ -4415,6 +4430,7 @@ static int bond_open(struct net_device *bond_dev) queue_delayed_work(bond->wq, &bond->mii_work, 0); if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ + bond_arp_reseed_slaves(bond); queue_delayed_work(bond->wq, &bond->arp_work, 0); WRITE_ONCE(bond->recv_probe, bond_rcv_validate); } diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 9efadeff6a223..1f40adc0b7fb1 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -1128,6 +1128,8 @@ static int bond_option_use_carrier_set(struct bonding *bond, static int bond_option_arp_interval_set(struct bonding *bond, const struct bond_opt_value *newval) { + bool start = !bond->params.arp_interval && newval->value; + netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n", newval->value); WRITE_ONCE(bond->params.arp_interval, newval->value); @@ -1150,9 +1152,11 @@ static int bond_option_arp_interval_set(struct bonding *bond, WRITE_ONCE(bond->recv_probe, NULL); cancel_delayed_work_sync(&bond->arp_work); } else { + cancel_delayed_work_sync(&bond->mii_work); + if (start) + bond_arp_reseed_slaves(bond); /* arp_validate can be set only in active-backup mode */ WRITE_ONCE(bond->recv_probe, bond_rcv_validate); - cancel_delayed_work_sync(&bond->mii_work); queue_delayed_work(bond->wq, &bond->arp_work, 0); } } diff --git a/include/net/bonding.h b/include/net/bonding.h index 5980df71a358e..fbd49a52b7378 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -708,6 +708,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb); int bond_set_carrier(struct bonding *bond); void bond_select_active_slave(struct bonding *bond); +void bond_arp_reseed_slaves(struct bonding *bond); void bond_change_active_slave(struct bonding *bond, struct slave *new_active); void bond_create_debugfs(void); void bond_destroy_debugfs(void); -- 2.56.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] bonding: reseed the ARP monitor when it starts 2026-12-01 10:20 ` [PATCH net-next 1/2] " Ramses de Norre via B4 Relay @ 2026-12-03 3:18 ` Hangbin Liu 2026-12-03 3:34 ` netdev-bot+sashiko 1 sibling, 0 replies; 7+ messages in thread From: Hangbin Liu @ 2026-12-03 3:18 UTC (permalink / raw) To: ramses Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Jakub Kicinski, Paolo Abeni, Jiri Bohac, Eric Dumazet, Willem de Bruijn, Simon Horman, netdev, linux-kernel, linux-kselftest, Nikolay Aleksandrov, Shuah Khan On Tue, Dec 01, 2026 at 12:20:29PM +0200, Ramses de Norre via B4 Relay wrote: > From: Ramses de Norre <ramses@well-founded.dev> > > When a slave is enslaved while the bond is down, the ARP monitor only > starts when the bond is brought up. When it is enslaved while the bond > uses miimon, the ARP monitor only starts when an arp_interval is set. In > both cases the monitor sees the timestamps that were seeded at enslave > time, which can be arbitrarily old. The first monitor run then marks the > UP slaves down before a single probe went out, and the bond comes back > on whichever slave answers first. With primary_reselect=failure it can > stay on the backup. > > systemd-networkd hits this with a bond that is brought up separately, > for example with ActivationPolicy=manual. > > The fix is to reseed the slaves when the ARP monitor starts. > > Link: https://lore.kernel.org/netdev/20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev/ > Signed-off-by: Ramses de Norre <ramses@well-founded.dev> > --- > drivers/net/bonding/bond_main.c | 58 ++++++++++++++++++++++++-------------- > drivers/net/bonding/bond_options.c | 6 +++- > include/net/bonding.h | 1 + > 3 files changed, 43 insertions(+), 22 deletions(-) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 754048ef4835d..a015f20e0718e 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1888,6 +1888,40 @@ void bond_xdp_set_features(struct net_device *bond_dev) > xdp_set_features_flag(bond_dev, val); > } > > +/* Seed a slave that is not UP outside the up window. Give a slave that is > + * UP a full arp_missed_max window. > + */ > +static void bond_arp_seed_slave(struct bonding *bond, struct slave *slave) > +{ > + unsigned long seed; > + int i; > + > + if (slave->link == BOND_LINK_UP) { > + slave->last_link_up = jiffies; > + seed = slave->last_link_up; > + } else { > + seed = jiffies - > + (2 * msecs_to_jiffies(bond->params.arp_interval) + 1); > + } > + > + WRITE_ONCE(slave->last_rx, seed); > + for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) > + WRITE_ONCE(slave->target_last_arp_rx[i], seed); > + WRITE_ONCE(slave->last_tx, seed); > +} > + > +/* Call before recv_probe is set and arp_work is queued. */ > +void bond_arp_reseed_slaves(struct bonding *bond) > +{ > + struct list_head *iter; > + struct slave *slave; > + > + ASSERT_RTNL(); > + > + bond_for_each_slave(bond, slave, iter) > + bond_arp_seed_slave(bond, slave); > +} > + > /* enslave device <slave> to bond device <master> */ > int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, > struct netlink_ext_ack *extack) > @@ -1896,7 +1930,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, > const struct net_device_ops *slave_ops = slave_dev->netdev_ops; > struct slave *new_slave = NULL, *prev_slave; > struct sockaddr_storage ss; > - int res = 0, i; > + int res = 0; > > if (slave_dev->type == ARPHRD_CAN || > slave_dev->type == ARPHRD_IEEE802154 || > @@ -2158,26 +2192,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, > BOND_SLAVE_NOTIFY_NOW); > } > > - /* 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 { > - /* 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 = 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; > - > - new_slave->last_tx = new_slave->last_rx; > + bond_arp_seed_slave(bond, new_slave); > > slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", > new_slave->link == BOND_LINK_DOWN ? "DOWN" : > @@ -4415,6 +4430,7 @@ static int bond_open(struct net_device *bond_dev) > queue_delayed_work(bond->wq, &bond->mii_work, 0); > > if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ > + bond_arp_reseed_slaves(bond); > queue_delayed_work(bond->wq, &bond->arp_work, 0); > WRITE_ONCE(bond->recv_probe, bond_rcv_validate); > } > diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c > index 9efadeff6a223..1f40adc0b7fb1 100644 > --- a/drivers/net/bonding/bond_options.c > +++ b/drivers/net/bonding/bond_options.c > @@ -1128,6 +1128,8 @@ static int bond_option_use_carrier_set(struct bonding *bond, > static int bond_option_arp_interval_set(struct bonding *bond, > const struct bond_opt_value *newval) > { > + bool start = !bond->params.arp_interval && newval->value; > + > netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n", > newval->value); > WRITE_ONCE(bond->params.arp_interval, newval->value); > @@ -1150,9 +1152,11 @@ static int bond_option_arp_interval_set(struct bonding *bond, > WRITE_ONCE(bond->recv_probe, NULL); > cancel_delayed_work_sync(&bond->arp_work); > } else { > + cancel_delayed_work_sync(&bond->mii_work); > + if (start) > + bond_arp_reseed_slaves(bond); > /* arp_validate can be set only in active-backup mode */ > WRITE_ONCE(bond->recv_probe, bond_rcv_validate); > - cancel_delayed_work_sync(&bond->mii_work); > queue_delayed_work(bond->wq, &bond->arp_work, 0); > } > } > diff --git a/include/net/bonding.h b/include/net/bonding.h > index 5980df71a358e..fbd49a52b7378 100644 > --- a/include/net/bonding.h > +++ b/include/net/bonding.h > @@ -708,6 +708,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); > u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb); > int bond_set_carrier(struct bonding *bond); > void bond_select_active_slave(struct bonding *bond); > +void bond_arp_reseed_slaves(struct bonding *bond); > void bond_change_active_slave(struct bonding *bond, struct slave *new_active); > void bond_create_debugfs(void); > void bond_destroy_debugfs(void); > > -- > 2.56.1 > > Thanks for the fix. Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] bonding: reseed the ARP monitor when it starts 2026-12-01 10:20 ` [PATCH net-next 1/2] " Ramses de Norre via B4 Relay 2026-12-03 3:18 ` Hangbin Liu @ 2026-12-03 3:34 ` netdev-bot+sashiko 1 sibling, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-12-03 3:34 UTC (permalink / raw) To: ramses Cc: jv, andrew+netdev, davem, kuba, pabeni, jbohac, edumazet, willemb, horms, netdev, linux-kernel, linux-kselftest, razor, hangbin.liu, shuah Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 3 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] bond_arp_seed_slave() breaks the invariant that the patch's own removed comment protected: "Not seeding it later than last_link_up… - [Low] This patch fixes a long-standing bug that users can hit, but the commit message has no Fixes: tag and no Cc: stable. - [Low] bond_arp_seed_slave() decides the seed from slave->link alone. - [Low] bond_arp_reseed_slaves() has the comment "Call before recv_probe is set and arp_work is queued", but bond_option_arp_interval_set()… -- bonding: reseed the ARP monitor when it starts This moves the enslave-time ARP timestamp seeding into a new helper, bond_arp_seed_slave(), and adds bond_arp_reseed_slaves(). The new function reseeds every slave when the ARP monitor starts, either from bond_open() or when arp_interval goes from 0 to nonzero on a running bond. Without the reseed, the first monitor run uses stale enslave-time timestamps and marks UP slaves down. Link: https://lore.kernel.org/netdev/20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev/ > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 754048ef4835d..a015f20e0718e 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1888,6 +1888,40 @@ void bond_xdp_set_features(struct net_device *bond_dev) > xdp_set_features_flag(bond_dev, val); > } > > +/* Seed a slave that is not UP outside the up window. Give a slave that is > + * UP a full arp_missed_max window. > + */ > +static void bond_arp_seed_slave(struct bonding *bond, struct slave *slave) > +{ > + unsigned long seed; > + int i; > + > + if (slave->link == BOND_LINK_UP) { > + slave->last_link_up = jiffies; > + seed = slave->last_link_up; > + } else { > + seed = jiffies - > + (2 * msecs_to_jiffies(bond->params.arp_interval) + 1); > + } [Severity: Medium] When a slave is not BOND_LINK_UP, this branch moves last_rx and target_last_arp_rx[] forward to jiffies - (2 * delta + 1) and leaves last_link_up alone. Can that make slave_last_rx() later than last_link_up for curr_active_slave? The code this patch removes from bond_enslave() said: 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. At enslave time a slave that is not UP can't be curr_active_slave, so the else branch did no harm there. At reseed time it can be. Take active-backup with miimon and downdelay > 0. During the downdelay window curr_active_slave sits in BOND_LINK_FAIL. Its last_link_up still holds the time bond_change_active_slave() made it active, which may be long ago. If arp_interval is set during that window, or the bond is reopened after such a switch, the else branch runs via: bond_option_arp_interval_set()->bond_arp_reseed_slaves()-> bond_arp_seed_slave() That makes this check in bond_arp_rcv() true right away: else if (curr_active_slave && time_after(slave_last_rx(bond, curr_active_slave), curr_active_slave->last_link_up)) bond_validate_arp(bond, slave, tip, sip); bond_na_rcv() has the same check. last_rx only moves forward, so the check stays true until last_link_up changes. Would backup slaves then validate broadcast ARP requests and NS messages with swapped addresses? That includes the bond's own probes when the switch reflects them back. The backups could then stay up even when the target is unreachable. bond_option_arp_validate_set() also doesn't reject arp_validate while miimon is active. > + > + WRITE_ONCE(slave->last_rx, seed); > + for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) > + WRITE_ONCE(slave->target_last_arp_rx[i], seed); > + WRITE_ONCE(slave->last_tx, seed); > +} > + > +/* Call before recv_probe is set and arp_work is queued. */ > +void bond_arp_reseed_slaves(struct bonding *bond) [ ... ] > @@ -4415,6 +4430,7 @@ static int bond_open(struct net_device *bond_dev) > queue_delayed_work(bond->wq, &bond->mii_work, 0); > > if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ > + bond_arp_reseed_slaves(bond); [Severity: Low] bond_arp_seed_slave() picks the seed from slave->link alone. On an ARP-only bond (arp_interval set, miimon=0), can slave->link be stale at this point? bond_enslave() sets the initial link from netif_carrier_ok() at enslave time. After that, nothing updates slave->link while the bond is down: - no monitor is running - bond_slave_netdev_event() only refreshes speed/duplex and the slave array on NETDEV_UP/CHANGE/DOWN - bond_close() doesn't reset it Suppose a slave had carrier at enslave and lost it before the bond was brought up. bond_open()->bond_arp_reseed_slaves() still sees BOND_LINK_UP and sets last_link_up, last_rx and last_tx to jiffies. bond_ab_arp_inspect() then skips that slave for the 2 * delta grace window. If it is curr_active_slave, it is only proposed down once last_rx leaves the missed_max window. With the defaults that is roughly 2.5 * arp_interval. During that time bond_xmit_activebackup() keeps sending to a slave with no carrier. Before the patch, the stale seed got it marked down on the first monitor run. Should bond_open() re-check carrier before reseeding, as bond_enslave() does for ARP-only bonds? If not, should the commit message mention this trade-off? [Severity: Low] This isn't a bug, but the commit message says systemd-networkd users hit this. Should the patch carry a Fixes: tag and Cc: stable? The enslave-only seeding goes back to commit f31c7937c254 ("bonding: start slaves with link down for ARP monitor") and commit 8e603460fa38 (last_link_up seeding). Commit 9231c2b6f180 ("bonding: give a slave that starts UP a full arp_missed_max window") also says this case was left as it was: 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. > queue_delayed_work(bond->wq, &bond->arp_work, 0); > WRITE_ONCE(bond->recv_probe, bond_rcv_validate); > } > diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c > index 9efadeff6a223..1f40adc0b7fb1 100644 > --- a/drivers/net/bonding/bond_options.c > +++ b/drivers/net/bonding/bond_options.c > @@ -1128,6 +1128,8 @@ static int bond_option_use_carrier_set(struct bonding *bond, > static int bond_option_arp_interval_set(struct bonding *bond, > const struct bond_opt_value *newval) > { > + bool start = !bond->params.arp_interval && newval->value; > + > netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n", > newval->value); > WRITE_ONCE(bond->params.arp_interval, newval->value); > @@ -1150,9 +1152,11 @@ static int bond_option_arp_interval_set(struct bonding *bond, > WRITE_ONCE(bond->recv_probe, NULL); > cancel_delayed_work_sync(&bond->arp_work); > } else { > + cancel_delayed_work_sync(&bond->mii_work); > + if (start) > + bond_arp_reseed_slaves(bond); [Severity: Low] The new bond_arp_reseed_slaves() has the comment "Call before recv_probe is set and arp_work is queued." Does this caller always meet that condition? bond_option_miimon_set() handles a switch from ARP to MII by setting arp_interval to 0 and cancelling arp_work, but it never clears bond->recv_probe. Going from nonzero to 0 in this function only clears recv_probe when arp_validate is set: if (bond->params.arp_validate) WRITE_ONCE(bond->recv_probe, NULL); In both cases recv_probe is still bond_rcv_validate when arp_interval later goes from 0 to nonzero on a running bond with start == true. The reseed then runs while bond_handle_frame()->bond_rcv_validate() can run in softirq on the slaves. With arp_validate=none, bond_rcv_validate() does: WRITE_ONCE(slave->last_rx, jiffies); and the reseed can overwrite that fresh receive with the down seed. With arp_validate set, bond_arp_rcv() and bond_na_rcv() read curr_active_slave->last_link_up locklessly. bond_arp_seed_slave() writes the same field with a plain store. When recv_probe was NULL, the reseed stores are not ordered with WRITE_ONCE(bond->recv_probe, bond_rcv_validate) by any release/acquire pair. A weakly ordered CPU could briefly see recv_probe set while still reading the old timestamps. bond_open() doesn't have this problem, because bond_close() clears recv_probe and calls synchronize_net(). Should the comment be relaxed, or should this path clear recv_probe and wait for readers before reseeding? > /* arp_validate can be set only in active-backup mode */ > WRITE_ONCE(bond->recv_probe, bond_rcv_validate); > - cancel_delayed_work_sync(&bond->mii_work); > queue_delayed_work(bond->wq, &bond->arp_work, 0); > } > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-bonding-arp-reseed-v1-0-984d4a3991cb%40well-founded.dev ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves when it starts 2026-12-01 10:20 [PATCH net-next 0/2] bonding: reseed the ARP monitor when it starts Ramses de Norre via B4 Relay 2026-12-01 10:20 ` [PATCH net-next 1/2] " Ramses de Norre via B4 Relay @ 2026-12-01 10:20 ` Ramses de Norre via B4 Relay 2026-12-03 3:23 ` Hangbin Liu 2026-12-03 3:35 ` netdev-bot+sashiko 1 sibling, 2 replies; 7+ messages in thread From: Ramses de Norre via B4 Relay @ 2026-12-01 10:20 UTC (permalink / raw) To: Jay Vosburgh, Andrew Lunn, David S. Miller, Jakub Kicinski, Paolo Abeni, Jiri Bohac, Eric Dumazet, Willem de Bruijn, Simon Horman Cc: netdev, linux-kernel, linux-kselftest, Nikolay Aleksandrov, Hangbin Liu, Shuah Khan, Ramses de Norre From: Ramses de Norre <ramses@well-founded.dev> Add a test for the two ways the ARP monitor can start after the slaves were enslaved: bringing the bond up after enslaving into it while it is down, and setting arp_interval on a running bond that uses miimon. In both cases the test waits longer than the arp_missed_max window before the monitor starts, and checks that the primary stays active and that no slave gets a link failure. Without the previous patch, both cases fail: the first monitor run takes both slaves down and the bond comes back on eth1, where it stays with primary_reselect=failure. Signed-off-by: Ramses de Norre <ramses@well-founded.dev> --- .../testing/selftests/drivers/net/bonding/Makefile | 1 + .../drivers/net/bonding/bond_arp_monitor_start.sh | 154 +++++++++++++++++++++ 2 files changed, 155 insertions(+) diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index 46d9fede59185..12276c942506e 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -6,6 +6,7 @@ TEST_PROGS := \ bond-break-lacpdu-tx.sh \ bond-eth-type-change.sh \ bond-lladdr-target.sh \ + bond_arp_monitor_start.sh \ bond_ipsec_offload.sh \ bond_lacp_independent_control.sh \ bond_lacp_prio.sh \ diff --git a/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh new file mode 100755 index 0000000000000..a718292172244 --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh @@ -0,0 +1,154 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Check that the ARP monitor does not take UP slaves down when it starts +# after the slaves were enslaved. That happens when the slaves are enslaved +# while the bond is down, or when arp_interval is set on a running bond +# that used miimon. The monitor must give the slaves a full arp_missed_max +# window from when it starts, not from when they were enslaved. +# +# +------------------------+ +# | bond0 192.0.2.1/24 | h_ns +# | eth0 eth1 | +# +---+-------------+------+ +# | | +# +---+-------------+------+ +# | sw0 sw1 | sw_ns +# | br0 192.0.2.254/24 | +# +------------------------+ + +# shellcheck disable=SC2034,SC2329 +ALL_TESTS=" + arp_monitor_start_on_open + arp_monitor_start_on_interval_set +" +REQUIRE_MZ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +# shellcheck disable=SC1091 +source "$lib_dir"/../../../net/forwarding/lib.sh + +require_command jq + +# Assigned by setup_ns. +h_ns="" +sw_ns="" + +ARP_INTERVAL=100 +# Longer than the arp_missed_max window of the slaves, so that their +# enslave time seeds are stale when the monitor starts. +ENSLAVE_WAIT=1 +# Let the monitor run several times before checking the slaves. +MONITOR_WAIT=1 + +setup_prepare() +{ + setup_ns h_ns sw_ns + defer cleanup_ns "$h_ns" "$sw_ns" + + ip -n "$sw_ns" link add br0 type bridge + ip -n "$sw_ns" link set br0 up + ip -n "$sw_ns" addr add 192.0.2.254/24 dev br0 + + for i in 0 1; do + ip -n "$h_ns" link add "eth$i" type veth \ + peer name "sw$i" netns "$sw_ns" + ip -n "$sw_ns" link set "sw$i" master br0 + ip -n "$sw_ns" link set "sw$i" up + done +} + +bond_create() +{ + ip -n "$h_ns" link add bond0 type bond mode active-backup \ + primary eth0 primary_reselect failure \ + arp_ip_target 192.0.2.254 "$@" + defer ip -n "$h_ns" link del bond0 + ip -n "$h_ns" addr add 192.0.2.1/24 dev bond0 +} + +bond_enslave() +{ + ip -n "$h_ns" link set eth0 master bond0 + ip -n "$h_ns" link set eth1 master bond0 +} + +active_slave_get() +{ + ip -n "$h_ns" -d -j link show bond0 | \ + jq -r '.[].linkinfo.info_data.active_slave' +} + +link_failures_get() +{ + local dev=$1; shift + + ip -n "$h_ns" -d -j link show "$dev" | \ + jq '.[].linkinfo.info_slave_data.link_failure_count' +} + +active_slave_is() +{ + [[ $(active_slave_get) == "$1" ]] +} + +slaves_check() +{ + local dev + + slowwait 5 active_slave_is eth0 + check_err $? "eth0 did not become the active slave" + + sleep "$MONITOR_WAIT" + + active_slave_is eth0 + check_err $? "eth0 is no longer the active slave" + for dev in eth0 eth1; do + [[ $(link_failures_get "$dev") == 0 ]] + check_err $? "$dev went down when the ARP monitor started" + done +} + +arp_monitor_start_on_open() +{ + RET=0 + + bond_create arp_interval "$ARP_INTERVAL" arp_validate all + bond_enslave + sleep "$ENSLAVE_WAIT" + ip -n "$h_ns" link set bond0 up + + slaves_check + + log_test "ARP monitor started by bringing the bond up" +} + +arp_monitor_start_on_interval_set() +{ + RET=0 + + bond_create miimon 100 + ip -n "$h_ns" link set bond0 up + bond_enslave + slowwait 5 active_slave_is eth0 + check_err $? "eth0 did not become the active slave with miimon" + sleep "$ENSLAVE_WAIT" + # arp_validate cannot be set while miimon is in use. bond_changelink() + # sets arp_interval first, which turns miimon off. + ip -n "$h_ns" link set bond0 type bond arp_interval "$ARP_INTERVAL" \ + arp_validate all + check_err $? "Failed to switch to the ARP monitor" + + slaves_check + + log_test "ARP monitor started by setting arp_interval" +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit "$EXIT_STATUS" -- 2.56.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves when it starts 2026-12-01 10:20 ` [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves " Ramses de Norre via B4 Relay @ 2026-12-03 3:23 ` Hangbin Liu 2026-12-03 3:35 ` netdev-bot+sashiko 1 sibling, 0 replies; 7+ messages in thread From: Hangbin Liu @ 2026-12-03 3:23 UTC (permalink / raw) To: ramses Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Jakub Kicinski, Paolo Abeni, Jiri Bohac, Eric Dumazet, Willem de Bruijn, Simon Horman, netdev, linux-kernel, linux-kselftest, Nikolay Aleksandrov, Shuah Khan Hi Ramses, On Tue, Dec 01, 2026 at 12:20:30PM +0200, Ramses de Norre via B4 Relay wrote: > From: Ramses de Norre <ramses@well-founded.dev> > > Add a test for the two ways the ARP monitor can start after the slaves > were enslaved: bringing the bond up after enslaving into it while it is > down, and setting arp_interval on a running bond that uses miimon. In > both cases the test waits longer than the arp_missed_max window before > the monitor starts, and checks that the primary stays active and that no > slave gets a link failure. > > Without the previous patch, both cases fail: the first monitor run takes > both slaves down and the bond comes back on eth1, where it stays with > primary_reselect=failure. > > Signed-off-by: Ramses de Norre <ramses@well-founded.dev> > --- > .../testing/selftests/drivers/net/bonding/Makefile | 1 + > .../drivers/net/bonding/bond_arp_monitor_start.sh | 154 +++++++++++++++++++++ > 2 files changed, 155 insertions(+) > > diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile > index 46d9fede59185..12276c942506e 100644 > --- a/tools/testing/selftests/drivers/net/bonding/Makefile > +++ b/tools/testing/selftests/drivers/net/bonding/Makefile > @@ -6,6 +6,7 @@ TEST_PROGS := \ > bond-break-lacpdu-tx.sh \ > bond-eth-type-change.sh \ > bond-lladdr-target.sh \ > + bond_arp_monitor_start.sh \ > bond_ipsec_offload.sh \ > bond_lacp_independent_control.sh \ > bond_lacp_prio.sh \ > diff --git a/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh > new file mode 100755 > index 0000000000000..a718292172244 > --- /dev/null > +++ b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh > @@ -0,0 +1,154 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Check that the ARP monitor does not take UP slaves down when it starts > +# after the slaves were enslaved. That happens when the slaves are enslaved > +# while the bond is down, or when arp_interval is set on a running bond > +# that used miimon. The monitor must give the slaves a full arp_missed_max > +# window from when it starts, not from when they were enslaved. > +# > +# +------------------------+ > +# | bond0 192.0.2.1/24 | h_ns > +# | eth0 eth1 | > +# +---+-------------+------+ > +# | | > +# +---+-------------+------+ > +# | sw0 sw1 | sw_ns > +# | br0 192.0.2.254/24 | > +# +------------------------+ > + > +# shellcheck disable=SC2034,SC2329 > +ALL_TESTS=" > + arp_monitor_start_on_open > + arp_monitor_start_on_interval_set > +" > +REQUIRE_MZ=no > +NUM_NETIFS=0 > +lib_dir=$(dirname "$0") > +# shellcheck disable=SC1091 > +source "$lib_dir"/../../../net/forwarding/lib.sh > + > +require_command jq > + [...] > + > +trap cleanup EXIT > + > +setup_prepare > +setup_wait Since we don't need the NUM_NETIFS, there is no need to call setup_wait. With that, we can include net/lib.sh directly, and remove the REQUIRE_MZ/NUM_NETIFS setting. Thanks Hangbin > + > +tests_run > + > +exit "$EXIT_STATUS" > > -- > 2.56.1 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves when it starts 2026-12-01 10:20 ` [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves " Ramses de Norre via B4 Relay 2026-12-03 3:23 ` Hangbin Liu @ 2026-12-03 3:35 ` netdev-bot+sashiko 1 sibling, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-12-03 3:35 UTC (permalink / raw) To: ramses Cc: jv, andrew+netdev, davem, kuba, pabeni, jbohac, edumazet, willemb, horms, netdev, linux-kernel, linux-kselftest, razor, hangbin.liu, shuah 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 comment in arp_monitor_start_on_interval_set()… -- selftests: bonding: test that the ARP monitor keeps UP slaves when it starts This adds a selftest for two ways the ARP monitor can start after the slaves are enslaved. In the first, the bond is brought up after slaves were enslaved while it was down. In the second, arp_interval is set on a running bond that uses miimon. In both cases the test checks that the primary stays active and that no slave records a link failure. > diff --git a/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh > new file mode 100755 > index 0000000000000..a718292172244 > --- /dev/null > +++ b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh [ ... ] > +arp_monitor_start_on_interval_set() > +{ > + RET=0 > + > + bond_create miimon 100 > + ip -n "$h_ns" link set bond0 up > + bond_enslave > + slowwait 5 active_slave_is eth0 > + check_err $? "eth0 did not become the active slave with miimon" > + sleep "$ENSLAVE_WAIT" > + # arp_validate cannot be set while miimon is in use. bond_changelink() > + # sets arp_interval first, which turns miimon off. [Severity: Low] This isn't a bug, but does this comment match what bond_changelink() does? In drivers/net/bonding/bond_netlink.c, the miimon that the arp_validate check uses is local to the request. It starts at 0, and it is only assigned when the same netlink message carries IFLA_BOND_MIIMON: bond_changelink() { int miimon = 0; ... if (data[IFLA_BOND_MIIMON]) { miimon = nla_get_u32(data[IFLA_BOND_MIIMON]); ... if (arp_validate && miimon) { NL_SET_ERR_MSG_ATTR(extack, data[IFLA_BOND_ARP_VALIDATE], "ARP validating cannot be used with MII monitoring"); return -EINVAL; } ... } bond_option_arp_validate_set() does not check miimon either. So the bond's current miimon state never blocks arp_validate. Handling IFLA_BOND_ARP_INTERVAL first, which clears bond->params.miimon, has no effect on whether arp_validate is accepted. It looks like a plain "ip link set bond0 type bond arp_validate all" on a bond running miimon would also be accepted. The combined command works because iproute2 does not send IFLA_BOND_MIIMON in that request. Could the comment be reworded or dropped so it does not describe a constraint and an ordering dependency that the kernel doesn't have? > + ip -n "$h_ns" link set bond0 type bond arp_interval "$ARP_INTERVAL" \ > + arp_validate all > + check_err $? "Failed to switch to the ARP monitor" [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-bonding-arp-reseed-v1-0-984d4a3991cb%40well-founded.dev ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-03 3:35 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-12-01 10:20 [PATCH net-next 0/2] bonding: reseed the ARP monitor when it starts Ramses de Norre via B4 Relay 2026-12-01 10:20 ` [PATCH net-next 1/2] " Ramses de Norre via B4 Relay 2026-12-03 3:18 ` Hangbin Liu 2026-12-03 3:34 ` netdev-bot+sashiko 2026-12-01 10:20 ` [PATCH net-next 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves " Ramses de Norre via B4 Relay 2026-12-03 3:23 ` Hangbin Liu 2026-12-03 3:35 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®