Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ramses@well-founded.dev
Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net,
	kuba@kernel.org, pabeni@redhat.com, jbohac@suse.cz,
	edumazet@kernel.org, willemb@google.com, horms@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, razor@blackwall.org,
	hangbin.liu@linux.dev, shuah@kernel.org
Subject: Re: [PATCH net-next v2 1/2] bonding: reseed the ARP monitor when it starts
Date: Fri, 04 Dec 2026 16:19:10 +0000	[thread overview]
Message-ID: <179640115000.3146.17224906099933916576@kernel.org> (raw)
In-Reply-To: <20261203-bonding-arp-reseed-v2-1-de49c2a3bb1e@well-founded.dev>

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] bonding: bond_arp_reseed_slaves() reseeds administratively
  down slaves
- [Low] The commit fixes a user-visible failover bug but has no Fixes:
  tag, and it does not say that it is meant for net-next only.
- [Low] Two places describe the aged seed jiffies - (2*delta + 1) as
  being outside "the up window": the comment on bond_arp_down_seed() and…
- [Low] In its UP branch, bond_arp_seed_slave() does a plain store
  `slave->last_link_up = jiffies` and then WRITE_ONCE(slave->last_rx,…

--

bonding: reseed the ARP monitor when it starts

This patch reseeds the per-slave ARP timestamps when the ARP monitor goes
from off to on, either in bond_open() or when arp_interval changes from 0
to non-zero. A slave that is UP and has carrier gets a fresh last_link_up
and a full arp_missed_max window. The timestamps of all other slaves are
only moved back, to the down seed.

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..bc66b130b765e 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1888,6 +1888,72 @@ void bond_xdp_set_features(struct net_device *bond_dev)
>  	xdp_set_features_flag(bond_dev, val);
>  }
>  
> +/* A timestamp outside the up window, see bond_time_in_interval(). */
> +static unsigned long bond_arp_down_seed(struct bonding *bond)
> +{
> +	return jiffies - (2 * msecs_to_jiffies(bond->params.arp_interval) + 1);
> +}
> +
> +/* 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 = bond_arp_down_seed(bond);
> +	}
> +
> +	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);
> +}

[Severity: Low]
Can a concurrent bond_arp_rcv() see the new last_rx together with the old
last_link_up here?

Before this patch, this pair was only written from bond_enslave(), before
netdev_rx_handler_register() published the slave. Through
bond_arp_reseed_slaves() it now also runs on live slaves.

In bond_option_arp_interval_set() with start == true, recv_probe can still
be bond_rcv_validate. Setting arp_interval=0 only clears it when
arp_validate was set, and the comment above bond_arp_reseed_slaves() notes
that recv_probe can still be set. For example:

  arp_interval=X, arp_validate=0
  arp_interval=0      (recv_probe stays bond_rcv_validate)
  arp_validate=all
  arp_interval=X      (start, bond_arp_reseed_slaves())

At the same time, on a backup slave in softirq:

bond_arp_rcv()
	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);

last_link_up is written with a plain store here. bond_arp_rcv() and
bond_na_rcv() read it with a plain load. There is no barrier between that
store and the WRITE_ONCE() of last_rx.

On a weakly ordered CPU, or if the compiler moves the plain store later,
could the reader see the fresh last_rx with the stale last_link_up? It
would then trust an ARP/NA on a backup slave before the active slave got
any reply.

The practical effect looks small. Still, would it make sense to annotate
last_link_up with WRITE_ONCE()/READ_ONCE() and order the two stores, with a
matching barrier on the read side? KCSAN would also report the plain
last_link_up access as a data race.

> +
> +static void bond_arp_age(unsigned long *ts, unsigned long seed)

[ ... ]

> +/* Reseed the slaves when the ARP monitor starts. A slave that is UP and has
> + * carrier gets a full arp_missed_max window from now. The timestamps of the
> + * other slaves are only moved back, out of the up window. Moving them
> + * forward could make an active slave that is not UP look like it got a
> + * reply, see bond_arp_rcv().

[ ... ]

> +void bond_arp_reseed_slaves(struct bonding *bond)
> +{
> +	unsigned long seed = bond_arp_down_seed(bond);
> +	struct list_head *iter;
> +	struct slave *slave;
> +	int i;
> +
> +	ASSERT_RTNL();
> +
> +	bond_for_each_slave(bond, slave, iter) {
> +		if (slave->link == BOND_LINK_UP &&
> +		    netif_carrier_ok(slave->dev)) {
> +			bond_arp_seed_slave(bond, slave);
> +			continue;
> +		}
> +
> +		bond_arp_age(&slave->last_rx, seed);
> +		for (i = 0; i < BOND_MAX_ARP_TARGETS; i++)
> +			bond_arp_age(&slave->target_last_arp_rx[i], seed);
> +		bond_arp_age(&slave->last_tx, seed);
> +	}
> +}

[Severity: Medium]
Should this test use bond_slave_is_up() instead of only
netif_carrier_ok()?

In bond_enslave() the seed comes right after dev_open() on the slave,
so the slave is known to be running there. bond_arp_reseed_slaves()
runs later, from bond_open() or bond_option_arp_interval_set(), and the
slave may have been brought administratively down in the meantime.

__dev_close_many() clears __LINK_STATE_START but leaves carrier alone
unless the driver's ndo_stop calls netif_carrier_off(), which dummy and
some other virtual or stacked devices don't do. The NETDEV_DOWN case in
bond_slave_netdev_event() doesn't change slave->link, no monitor runs
while the bond is down, and bond_open() doesn't reopen slaves. For
example, in active-backup mode with arp_interval set:

  ip link set bond0 down
  ip link set eth0 down    (carrier stays on, slave->link stays UP)
  ip link set bond0 up     (bond_arp_reseed_slaves())

eth0 then passes this check and gets last_link_up = jiffies plus fresh
last_rx and last_tx. If it is the active slave, the grace check on
last_link_up in bond_ab_arp_inspect() keeps it UP for about
2.5 * arp_interval, and bond_loadbalance_arp_mon() keeps such a slave
for about missed_max intervals in the other modes. Meanwhile traffic
keeps going to a stopped device. bond_loadbalance_arp_mon() itself
won't send probes on such a slave, since it tests bond_slave_is_up().

bond_slave_is_up() checks netif_running() as well as
netif_carrier_ok(), and it's what bond_slave_can_tx() and the ARP
monitors already use. The commit message says requiring carrier keeps
a slave that went away while the bond was down from getting a grace
period; that doesn't hold for a stopped slave whose driver leaves
carrier on. Would bond_slave_is_up() be the right test here, or is
there a reason to give a stopped slave the UP seed?

[Severity: Low]
Is "out of the up window" accurate for every slave that takes the aging
path?

bond_time_in_interval() accepts:

	return time_in_range(jiffies,
			     last_act - delta_in_ticks,
			     last_act + mod * delta_in_ticks + delta_in_ticks/2);

So a timestamp of jiffies - (2 * delta + 1) is outside only the mod=1
window. That is the test that brings a slave up.

Slaves with link == BOND_LINK_UP but no carrier also take the aging path.
For them, the stay-up tests use larger windows:

  bond_ab_arp_inspect(), active slave: missed_max
  bond_ab_arp_inspect(), backup slave: missed_max + 1
  bond_loadbalance_arp_mon(): missed_max

The active-slave check in bond_ab_arp_inspect() is:

		if (bond_is_active_slave(slave) &&
		    (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) ||
		     !bond_time_in_interval(bond, last_rx, bond->params.missed_max))) {

With the default missed_max=2 and delta >= 2 ticks, the upper bound is
jiffies + delta/2 - 1. Suppose the monitor restarts soon after the last
rx/tx, from a quick bond down/up or arp_interval 0->X. A carrier-less
active slave whose timestamps were newer than the seed then survives the
first monitor run and goes down one interval later. A backup survives two
runs.

The commit message also says:

  Requiring carrier keeps a slave that lost its link while the bond was
  down from getting a grace period.

Such a slave still keeps up to (missed_max - 2) * delta + delta/2 of
window.

This isn't a regression compared with the old behaviour, which kept the
original, newer timestamps. Could the comment here, the one on
bond_arp_down_seed(), and the commit message say that the seed is only
outside the mod=1 up window?

[ ... ]

> @@ -4415,6 +4462,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);
>  	}

[Severity: Low]
This isn't a bug in the code, but should this patch have a Fixes: tag, or a
note that it is meant for net-next only?

The stale enslave-time seed is long-standing. When the monitor starts late,
the first bond_ab_arp_inspect() run gets past the grace check:

		if (bond_time_in_interval(bond, slave->last_link_up, 2))
			continue;

It then marks healthy UP slaves down before any probe goes out.

The earlier commit 9231c2b6f180 ("bonding: give a slave that starts UP a
full arp_missed_max window") explicitly left the late-start case out. It
went to net-next without a Fixes: tag, so leaving the tag off here may be
on purpose. Without a tag or a note, though, stable maintainers can't tell
which kernels are affected or whether to backport.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-bonding-arp-reseed-v2-0-de49c2a3bb1e%40well-founded.dev

  reply	other threads:[~2026-12-04 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:27 [PATCH net-next v2 0/2] bonding: reseed the ARP monitor when it starts Ramses de Norre via B4 Relay
2026-12-03 15:27 ` [PATCH net-next v2 1/2] " Ramses de Norre via B4 Relay
2026-12-04 16:19   ` netdev-bot+sashiko [this message]
2026-12-03 15:27 ` [PATCH net-next v2 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves " Ramses de Norre via B4 Relay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179640115000.3146.17224906099933916576@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hangbin.liu@linux.dev \
    --cc=horms@kernel.org \
    --cc=jbohac@suse.cz \
    --cc=jv@jvosburgh.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ramses@well-founded.dev \
    --cc=razor@blackwall.org \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox