🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23351

Re: [PATCH net 2/3] bonding: update slave array on link change for broadcast mode

#23351
From: Hangbin Liu
Date: Fri, 27 Nov 2026 06:00
167 lines
15461 bytes
On Fri, Nov 27, 2026 at 03:15:57AM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 2 · Low: 1
> 
> 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] The commit message says the patch makes the broadcast
>   usable_slaves snapshot 'follow link transitions the same way balance-…
> - [Medium] Because broadcast now publishes usable_slaves (the revert,
>   which this patch relies on), switching a broadcast bond to balance-rr…
> - [Low] The series ordering is not bisect-safe, and the dependency
>   between the two patches is not recorded in tags.
> 
> --
> 
> bonding: update slave array on link change for broadcast mode
> 
> This adds a BOND_MODE_BROADCAST case to bond_miimon_link_change(), so the
> usable_slaves snapshot is rebuilt on miimon link transitions. That keeps
> the ignore_updelay decision in bond_miimon_inspect() in line with the
> current slave link states. It depends on a revert of 45fc134bcfad so that
> bond_set_slave_arr() publishes the array for broadcast.
> 
> > Add the broadcast case so the snapshot follows link transitions the
> > same way balance-xor does. This needs the revert of 45fc134bcfad as
> > a prerequisite: with 45fc134bcfad applied, bond_set_slave_arr()
> > discards the refreshed array for broadcast.
> >
> > Fixes: e0caeb24f538 ("net: bonding: update the slave array for broadcast mode")
> 
> [Severity: Low]
> Is the series order bisect-safe? The revert of 45fc134bcfad is applied
> before this patch. On its own, it makes bond_set_slave_arr() publish
> usable_slaves for broadcast again, but nothing rebuilds the array on
> miimon link changes yet.
> 
> At that intermediate commit, a batch enslave with updelay leaves the new
> slaves in BOND_LINK_BACK. The snapshot taken at enslave time then has
> count == 0 and is never refreshed, so bond_miimon_inspect() ignores
> updelay permanently. That is the bug 45fc134bcfad fixed.
> 
> If this patch went first, it would be a no-op under 45fc134bcfad, and
> every commit in the series would be correct.
> 
> Also, this patch carries Fixes: e0caeb24f538, but the revert it depends on
> has no Fixes: tag and no dependency annotation. 45fc134bcfad is likely
> already in stable trees.
> 
> Would a tag-driven backport of only this patch leave the stale snapshot
> behaviour unchanged there?

This commit description already said it depends on the revert.

> 
> > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> > index d6675e87d06b6..b1efbdf597ec4 100644
> > --- a/drivers/net/bonding/bond_main.c
> > +++ b/drivers/net/bonding/bond_main.c
> > @@ -2780,6 +2780,7 @@ static void bond_miimon_link_change(struct bonding *bond,
> >  		bond_alb_handle_link_change(bond, slave, link);
> >  		break;
> >  	case BOND_MODE_XOR:
> > +	case BOND_MODE_BROADCAST:
> >  		bond_update_slave_arr(bond, NULL);
> >  		break;
> >  	}
> 
> [Severity: Medium]
> The commit message says the snapshot follows link transitions "the same
> way balance-xor does". Does that hold outside the MII monitor?
> 
> balance-xor also rebuilds the array when the ARP load-balance monitor
> changes a slave's link state. Broadcast is still left out there:
> 
> drivers/net/bonding/bond_main.c:bond_loadbalance_arp_mon() {
>     ...
> 		if (slave_state_changed) {
> 			bond_slave_state_change(bond);
> 			if (BOND_MODE(bond) == BOND_MODE_XOR)
> 				bond_update_slave_arr(bond, NULL);
> 		}
>     ...
> }
> 
> Broadcast can use ARP monitoring, because bond_mode_uses_arp() only
> excludes BOND_MODE_8023AD, BOND_MODE_TLB and BOND_MODE_ALB.
> bond_slave_netdev_event() also skips broadcast, since
> bond_mode_can_use_xmit_hash() is false for it. So under ARP monitoring,
> the broadcast snapshot keeps the state from the last enslave or release.
> 
> bond_option_miimon_set() can switch the bond from ARP monitoring to
> miimon at runtime. It zeroes arp_interval, cancels arp_work and queues
> mii_work, but it does not rebuild the slave array. params.updelay
> survives the switch.
> 
> For example, slaves enslaved with carrier under ARP monitoring are marked
> BOND_LINK_UP and counted in usable_slaves. Later the ARP monitor marks
> them BOND_LINK_DOWN, but the snapshot is not refreshed. Once miimon is
> enabled, bond_miimon_inspect() sees usable_slaves->count != 0:
> 
> 	if (usable_slaves && usable_slaves->count == 0)
> 		ignore_updelay = true;
> 
> Recovering slaves then wait out updelay even though the bond has no usable
> link.
> 
> The reverse case also happens. If slaves are enslaved without carrier,
> count == 0 and updelay is wrongly ignored. Either state lasts until the
> first miimon commit reaches bond_miimon_link_change().
> 
> Should BOND_MODE_BROADCAST also be added to the condition in
> bond_loadbalance_arp_mon()?

Ack, I will also handle the arp monitor.

> 
> [Severity: Medium]
> Now that broadcast publishes usable_slaves, does a switch from broadcast
> to balance-rr leave a stale snapshot behind?
> 
> Releasing the last broadcast slave goes through __bond_release_one():
> 
> 	if (bond_mode_can_use_xmit_hash(bond) ||
> 	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
> 		bond_update_slave_arr(bond, slave);
> 
> This runs after bond_upper_dev_unlink(), so the slave list is already
> empty. The result is a non-NULL usable_slaves with count == 0, and after
> the revert that array is kept for broadcast.
> 
> Neither bond_option_mode_set() nor bond_close() resets the arrays.
> 
> In balance-rr, nothing rebuilds the array afterwards:
> 
>   - bond_enslave() and __bond_release_one() only rebuild for xmit-hash
>     modes or broadcast
>   - bond_open() and bond_slave_netdev_event() only rebuild when
>     bond_mode_can_use_xmit_hash() is true
>   - bond_miimon_link_change() has no BOND_MODE_ROUNDROBIN case
> 
> So in balance-rr, bond_miimon_inspect() would see count == 0 on every
> pass. It would set ignore_updelay = true and force slave->delay to 0 for
> every recovering slave.
> 
> Documentation/networking/bonding.rst section 13.1 says updelay is ignored
> only when the bond has no active links.
> 
> In the baseline tree with 45fc134bcfad, broadcast never published
> usable_slaves, so a switch from broadcast to balance-rr left it NULL. The
> same missing reset on mode change already existed for a switch from
> balance-xor to balance-rr.

This seems not broadcast only issue. The other xmit hash mode also have this
problem. Maybe we should set usable_array to NULL if it's length is 0? Need
to further checking.

Thanks
Hangbin
---
pw-bot: cr
Technical Details
Message-ID: <awkcmoDW5AHqJujs@fedora>
Path: mbox-mo1.pugleaf.net!srv.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-372476-linux-kernel-netdev=dewy.ru
References: <20261126-bond_broadcast_updelay-v1-2-188e5538d6ca@kylinos.cn> <179574935712.3135.18271637068349106750@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-372476-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/3] bonding: update slave array on link change for
 broadcast mode
Date: Fri, 27 Nov 2026 14:00:58 +0800
Organization: Usenet Network
Message-ID: <awkcmoDW5AHqJujs@fedora>
References: <20261126-bond_broadcast_updelay-v1-2-188e5538d6ca@kylinos.cn>
 <179574935712.3135.18271637068349106750@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="653208"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0i09Tel0g6pHcnfwRQhBbDO0tfI= sha256:LLI6axs1EKgQ2Cowwq1MItHTgtABnjnbpp5mqUoovTU=
	sha1:4UMBDi63sRrsDjBS+Tco/9oazMI= sha256:VVCRqWIgAHxyKffjUiLjWLxAZdwkej9lJh2lV2iUwVA=
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 004B0125F11; Fri, 27 Nov 2026 09:01:45 +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 QbAulFbao9rl;
	Fri, 27 Nov 2026 09:01:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372476-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 0ACD1125F0D; Fri, 27 Nov 2026 09:01:20 +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 BFE042C442; Fri, 27 Nov 2026 06:01:17 +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=1795759274;
	b=U1tXdjGphZMXRygKBbjv/vTpcszb0MduvVpmb8xnVpz5M4PW89h4vliGdNj04mcXAC2q
	 E3KQ+BFv9N1KmzCFiZ3gvWAna7/kgYFppxQS6+/APzFUvvxsaCowB8SqHrBMhwngbnZ2g
	 Gt9WLD+R4BTeQfU/RwBmsjLj2494Yq/D/ji6wFJpjWzFUbX+oDE9YJoFJBr3VAfgxKWqU
	 xfkx/bHEaUc0hCePsyLwf3yLg+6M0QqSk3rDSXC9CbK3dWvOXF+2g4LS8un553REFMmfv
	 15xN2CZkRj39PNlrKiemtoA0qiYigJVbdTxXdtRtX8YycfObpzdU/FxIwTobx/n+Jzg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795759274;
	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:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=nrXUyBnnLMn4mqMV0QE9b5zcQInsdQBriad2AyK2+Eo=;
	b=Vr0VZypiOvj2ps/rZ0Ql3u5+PfUSs0bo1gN12di0WrUdOIhv1OiyMQL25reo7lNgaqte
	 AGxVy0geimtogTJAs6LKQ//SUqiExXQyss9SqxL/2tMzWNU6Rug1DuI/hIOxTACAg8beF
	 j17V88c0e5NRTOo2wiiRk/deV8Rh0ZSnfC+EkLQ++Az3Hjew34WuJzNqKZIf3L/GvCs9w
	 ++Fa3v1dvEUmUKZiyfJrqh5MWdMVrOlAXVOLZovi70VZkJQk4BD4iLSlr4kc+CYW2HHFh
	 vqmx0m5tOmpWSY+N3H5iF+nStJh8WCMgvnrmWViNm1O90M/SqZ6cZGy09tgdIIIPQOg==
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=Y5sBkEAp;
	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 9C184606A330;
	Fri, 27 Nov 2026 06:01:14 +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=Y5sBkEAp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.75
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795759273;
	b=R4lZ9k3Pye9+qgkLK7wD4bLOcF7PfYagzu0xjwv6d/xVV8BB3ZDlESvyrtv1giTs6tt6
	 XgKL7LzRaHOke31N5/wi03ke+RwB0LcOJZhHtsT8KAjOMQw7q194Ol8ohJmVZQTVGoXGy
	 M0BGVFq9reLVHl21S+6peuHwZrPGerddvjwsjhHWOBGBhXkETcPJiYpFvDK/jQSqoj1Ag
	 cJ3Ql/UpYCyyw1lfr1fEL8Ut1292leiq9TknTprbkfhbWN4alg0CbHXxVUf5cDmLmJOXR
	 LSayfCyt52R4V+2YQOra+9mf7WMLGOejRLDdqW/hh5PmSgeaugH7o29TCI/odkiusbA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795759273;
	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:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=nrXUyBnnLMn4mqMV0QE9b5zcQInsdQBriad2AyK2+Eo=;
	b=TOHvLRVtpqv/HVD70/OB01v91bwtHnUMfyxnVCWl0PQykDriSwVdYX/L9/KAaPh3wChA
	 oJMvY//VGmWBfD9qyxDHNB5gY8dw3IcPmQxtlbCE5qAstPg7CABre1zwdOQc+wEZoxbU2
	 dNCrfxsshKtc57YTJPvbfAEwzvqSehrrljfe3ApskKNkIZJMZTs6JW6G1V7D7L+SK3Wt5
	 3CE7IY8YPCcPx6lmBxu97OVwDEy20UEE3tBsrpb8+vQz6LQXix1/wbP9+ZhxZCr2+bNbK
	 pQAEvhoYkWO/ewKL9LV5XPQu0p9ZS79Htw/9JoLasAXyOsWszJrSbBkHOZJ1cHXaQ8w==
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=Y5sBkEAp;
	arc=none smtp.remote-ip=91.218.175.75
X-Received: from mta0.migadu.com (out-75.mta0.migadu.com [91.218.175.75])
	(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 AAF92606A321
	for <netdev@vger.kernel.org>; Fri, 27 Nov 2026 06:01:12 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AAF92606A321
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=7VngrNZEXiKoDUMjMc/nzPenWV2Zy0/emms0Y+lumzs=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1795759270; v=1; x=1796364070;
 b=Y5sBkEApFsaG7tDNVA61iRZ4F35l421r6lYOjienw2wc71fpUfYJS4oFsuZOprbajPMWb2Kd
 9usp5H8ixhueAERbI0YLoOwHmmbj1ZDIMlXKoxFC3spponR6w+jpLJl2ott7gOdh7Vz3+vTY7NP
 PXHHL3qGfL5jdPEUKM7zdtKo=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta10.migadu.com with ESMTPS id 9ad39df9598d294b;
	Fri, 27 Nov 2026 06:01:10 +0000
X-Mizu-Trace-ID: 9ad39df9598d294b
X-Migadu-Flow: FLOW_OUT
X-Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	tonghao@bamaicloud.com, razor@blackwall.org, shuah@kernel.org,
	jiangjiehua1@huawei.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.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: <179574935712.3135.18271637068349106750@kernel.org>