🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26116

Re: [PATCH net-next 1/2] bonding: reseed the ARP monitor when it starts

#26116
From: Hangbin Liu
Date: Thu, 03 Dec 2026 03:18
163 lines
15246 bytes
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>
Technical Details
Message-ID: <axDfi_HcvcZoHMwe@fedora>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376252-linux-kernel-netdev=dewy.ru
References: <20261201-bonding-arp-reseed-v1-0-984d4a3991cb@well-founded.dev> <20261201-bonding-arp-reseed-v1-1-984d4a3991cb@well-founded.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376252-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 1/2] bonding: reseed the ARP monitor when it
 starts
Date: Thu, 3 Dec 2026 11:18:35 +0800
Organization: Usenet Network
Message-ID: <axDfi_HcvcZoHMwe@fedora>
References: <20261201-bonding-arp-reseed-v1-0-984d4a3991cb@well-founded.dev>
 <20261201-bonding-arp-reseed-v1-1-984d4a3991cb@well-founded.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2130167"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5mh9NRQ9s+W39ds9wA/hpYRhCns= sha256:d6Rm2YozoBan2TiWzEwjQPuhtWF3lkHZk0iowyRsGpk=
	sha1:Q711nbbBl9seICUqIM/LfDhv590= sha256:UqGRrH6yShqb3tOBhi6o7UAF/LLeLjiyBkU8JBn759U=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id DD6971177FB; Thu,  3 Dec 2026 06:19:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 8GSR0KeRCBQ9;
	Thu,  3 Dec 2026 06:19:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376252-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 700871177F9; Thu,  3 Dec 2026 06:18:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id C6DC1289F2; Thu,  3 Dec 2026 03:18:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796267932;
	b=iMc24UqO4BlloKY+d6hOPzejFdx3U+luNLAJwXS/qP4FGYPg8HZ4W908e2dVdrpDNpqL
	 fxpS35xEpLyZ3pIgWjWwJSc9lBw/MVcMpGz1lRc/xQHfx1Lyc8jZQiCQ51lrQBlU5V4Ea
	 OOOzZAnDE0T+wmTXoBCicoxGrmJUO19u5j6m71ZPZM/KZrsrcLMk8gBLWV4AqmhG01G8S
	 LVjHKlFL+AvEk9yQBB3E3Z80iQFluJ9NBknodZiJvG/eNl7u7j73IHC2K3k+x93NNIN4w
	 Pabba8xlYkY4Xt6tsXsDZbaMY1lP0v9mhGMFg4smdX6y8swec4ZAH4QAKOLU/3qiyYA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796267932;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=IqZ3gVhFbTQzC+emiGWQmj6KmWWQmQcRak3lfYThPHg=;
	b=i1xFbVU+8eJPAMKrqlSxdwEzIZuuRBuA7HKIyk+6UDf6F345fF/uDS56KogMINogDfXy
	 Re6XVDX6cV8avjTNXRkG24O5ynQzu/4senEE9oOJww91peLtFI9wbvsVuA9vEcy4B89gj
	 MbpTVqw6EqHLbZzBpoioervYkdg/2uD4hJ5iUAShLEWdUkTNgF6WUUyi8zhJJsw6iJptb
	 xNIBOGJRRpulJOUxz2P7+MTpEn8EM9DbAq6TZa/SS2w6hDFxvBM2xg/SIO4h/NReILuSV
	 +6YnR0Z0WTt0IEhJUP29P6QHmj1kIUGEeGmIq9ol04PtJv6jBMxnEHlqkbGuYM1GeLw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="STMLz/kM";
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C956606A33D;
	Thu,  3 Dec 2026 03:18:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=STMLz/kM
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.4
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796267931;
	b=xcUT6PdkQ3zVqIvSlmqspnxSfnqMRECVvKAxmdyrgBtHw8Zl5v/4rvuhGy2EXUC7DThD
	 LqPmClipzMmFYyxxUAZ0U1GBaagQoSZJctCdBgOP/UUodC6mtssdAjUDc2du7cALLeAnW
	 Da4Yyw/R/+JCRYjEEEIhxQqJm37Ito5Lwu9Ci5dbCr62CxPQV3wS8PKXgPcHDDIgcuH1n
	 GJbSaTMc65iLodzdX+appDcBleBTfekSQfci9Hc+k5ee53ZMaRTFp4E1gTaIioccBN71P
	 B6RYZO1zjGNcOgUClR5mxjA4YMG/48kz5/RYskl1jWC8rGTpkunKyd5E05+N/IvQfcA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796267931;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=IqZ3gVhFbTQzC+emiGWQmj6KmWWQmQcRak3lfYThPHg=;
	b=sY6fLfEm/F5SRWd59awhCWNMvZDJktwRV/XFa6FM71tFp3Fi4GHQXhkb0O+KfU6ht/f8
	 7ApHPpqONpscioCOvcXHUkmZxZE7y4RH76ypb6uQFu8L2cLGosVixHL3VWiacbgA8hysL
	 dfIpXbYzFEM2HXf+DEbhLGn0prHXSEE/97X/PeUNm9AEwDPWPaojdi0LUyyfhO8+bSd+9
	 NNmeNbmd8zs8P/bY7UCVZCtQw2uZw0dWGQlewhfmPMJfzQbJUDFI3C8j59wa2aHGr78IT
	 u0rApNyNFwMJxrpD4F25mFEUCiM4hpCKCmJaFlYxZ5+G5/oX7YWQGfJcKqqo8s4xvEg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="STMLz/kM";
	arc=none smtp.remote-ip=95.215.58.4
X-Received: from mta1.migadu.com (out-4.mta1.migadu.com [95.215.58.4])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79807606A32F
	for <netdev@vger.kernel.org>; Thu,  3 Dec 2026 03:18:50 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79807606A32F
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=42GLcIiLqy5ui/4O9dmJkQOmXjoUmroJAJh1zrWbw2A=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1796267928; v=1; x=1796872728;
 b=STMLz/kMBPuT3gx3t/OSGNLG3j1W2Vigqm2MfwbBZv9pFn6uSpPAqxmUJ5ie667NfY8lB6Rv
 uaOl2zorO9dbA/QJOazNwVWXVlxyWqkEp6plk/nzmQg/23BHgeaOC/Bt8wcEYS/+XK4JW6Mudmh
 zcePkKDN1tVCIO+TkOZIpw+w=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta12.migadu.com with ESMTPS id 52d892bf636a1e51;
	Thu, 03 Dec 2026 03:18:48 +0000
X-Mizu-Trace-ID: 52d892bf636a1e51
X-Migadu-Flow: FLOW_OUT
X-Cc: Jay Vosburgh <jv@jvosburgh.net>, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jiri Bohac <jbohac@suse.cz>, Eric Dumazet <edumazet@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Shuah Khan <shuah@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261201-bonding-arp-reseed-v1-1-984d4a3991cb@well-founded.dev>