🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8426

Re: [PATCH net v2] bonding: fix missing down path on speed/duplex failure after FAIL->UP

#8426
From: Hangbin Liu
Date: Thu, 29 Oct 2026 01:49
182 lines
15883 bytes
Hi Timur,
On Wed, Oct 28, 2026 at 12:47:57PM +0200, Timur Stukan wrote:
> In bond_miimon_commit(), when a slave is proposed as BOND_LINK_UP but
> bond_update_speed_duplex() fails in bonding mode that needs speed/duplex
> (802.3ad, tlb, alb), the slave is set to BOND_LINK_DOWN directly. This
> bypasses bond_set_slave_link_state(), bond_miimon_link_change() and
> failover.
> 
> This is fine for slave that coming from BOND_LINK_BACK, which was never
> brought up and is not in use. But since commit 1899bb325149 ("bonding:
> fix state transition issue in link monitoring") the commit phase also
> handles BOND_LINK_FAIL -> BOND_LINK_UP which means a slave that is still
> in use and may be curr_active_slave.
> 
> If the link recovers within downdelay and goes down again before the
> commit phase reads speed/duplex, the slave is silently marked down while
> remaining the active slave in worst cases. In alb/tlb the bond MAC stays
> on the dead port, no failover happens and TLB/RLB state is not cleaned,
> so the bond stops passing traffic until that link comes back even though
> other slaves are up. A non-active slave is affected too, in alb, RLB
> clients assigned to it are not reassigned and become unreachable.
> 
> Reproduced in tlb and alb mode with miimon=100 and downdelay=10000 by
> flapping a slave within downdelay and dropping it again before commit
> (a longer delay was added between inspect and commit to make window
> wider and easier to test):
>   bond0: (slave enp0s3): link status down for interface, disabling it in 10000 ms
>   bond0: (slave enp0s3): link status up again after 3400 ms
>   bond0: (slave enp0s3): failed to get link speed/duplex
> 
> procfs then shows the active slave with "MII Status: down" and "Link
> Failure Count: 0", and all traffic is lost.
> 
> Fix this by not committing UP proposals in bond_mii_monitor(): UP is
> already committed by bond_miimon_commit() once speed/duplex are valid, so
> leaving it there means slave->link still holds the previous state at
> that point. When speed/duplex update fails for a slave coming from
> BOND_LINK_FAIL, take it through the regular down path, including
> failover. Slaves coming from BACK/DOWN keep the current behaviour.
> The down path is moved into bond_miimon_slave_down() so both callers share it.
> 
> After the fix:
>   bond0: (slave enp0s3): failed to get link speed/duplex
>   bond0: (slave enp0s3): link status definitely down, disabling slave
>   bond0: (slave enp0s4): making interface the new active one
> 
> Fixes: 1899bb325149 ("bonding: fix state transition issue in link monitoring")
> Signed-off-by: Timur Stukan <timur.stukan.linux@gmail.com>
> ---
> 
> Notes:
>     Changes in v2:
>     - Drop link_prev_state. Instead, don't commit UP proposals in
>       bond_mii_monitor() and let bond_miimon_commit() commit them after the
>       speed/duplex check, so no extra state is needed (Jay)
>     - v1: https://lore.kernel.org/netdev/20261022103821.89552-1-timur.stukan.linux@gmail.com/
>     
>     Sashiko pointed out on v1 that the 802.3ad netdev notifier can set
>     BOND_LINK_FAIL on a slave that is already down, which then goes through
>     the full down path again. That is pre-existing and reproducible on an
>     unpatched net tree:
>     
>       ip link add bond0 type bond mode 802.3ad miimon 100 lacp_rate 1
>       ip link set enp0s3 down
>       ip link set enp0s4 down
>       ip link set enp0s3 master bond0
>       ip link set enp0s4 master bond0
>       ip link set enp0s3 up
>       ip link set enp0s4 up
>       ip link set bond0 up
>       (wait for LACP to settle)
>       ip link set enp0s3 down
>       ip link set enp0s3 up
>     
>     "link status definitely down" is logged twice and enp0s3 ends up with
>     "Link Failure Count: 2" instead of 1. I will send a separate fix for it.
> 
>  drivers/net/bonding/bond_main.c | 58 +++++++++++++++++++++++----------
>  1 file changed, 40 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 7019e5d8fdc8..9bafcddbb453 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2779,6 +2779,27 @@ static void bond_miimon_link_change(struct bonding *bond,
>  	}
>  }
>  
> +static bool bond_miimon_slave_down(struct bonding *bond,
> +				   struct slave *slave)
> +{
> +	if (slave->link_failure_count < UINT_MAX)
> +		slave->link_failure_count++;
> +
> +	bond_set_slave_link_state(slave, BOND_LINK_DOWN,
> +				  BOND_SLAVE_NOTIFY_NOW);
> +
> +	if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
> +	    BOND_MODE(bond) == BOND_MODE_8023AD)
> +		bond_set_slave_inactive_flags(slave,
> +					      BOND_SLAVE_NOTIFY_NOW);
> +
> +	slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n");
> +
> +	bond_miimon_link_change(bond, slave, BOND_LINK_DOWN);
> +
> +	return slave == rcu_access_pointer(bond->curr_active_slave);
> +}
> +
>  static void bond_miimon_commit(struct bonding *bond)
>  {
>  	struct slave *slave, *primary, *active;
> @@ -2807,10 +2828,21 @@ static void bond_miimon_commit(struct bonding *bond)
>  			err = bond_update_speed_duplex(slave);
>  			netdev_unlock_ops(slave->dev);
>  			if (err && bond_needs_speed_duplex(bond)) {
> -				slave->link = BOND_LINK_DOWN;
>  				if (net_ratelimit())
>  					slave_warn(bond->dev, slave->dev,
>  						   "failed to get link speed/duplex\n");
> +				/* Coming from FAIL, the slave is still in
> +				 * use and may be curr_active_slave, so take
> +				 * it through the full down path. Coming from
> +				 * DOWN/BACK, it was never brought up, so just
> +				 * revert it to DOWN.
> +				 */
> +				if (slave->link == BOND_LINK_FAIL) {
> +					if (bond_miimon_slave_down(bond, slave))
> +						do_failover = true;
> +					continue;
> +				}
> +				slave->link = BOND_LINK_DOWN;
>  				continue;
>  			}
>  			bond_set_slave_link_state(slave, BOND_LINK_UP,
> @@ -2839,24 +2871,8 @@ static void bond_miimon_commit(struct bonding *bond)
>  			continue;
>  
>  		case BOND_LINK_DOWN:
> -			if (slave->link_failure_count < UINT_MAX)
> -				slave->link_failure_count++;
> -
> -			bond_set_slave_link_state(slave, BOND_LINK_DOWN,
> -						  BOND_SLAVE_NOTIFY_NOW);
> -
> -			if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
> -			    BOND_MODE(bond) == BOND_MODE_8023AD)
> -				bond_set_slave_inactive_flags(slave,
> -							      BOND_SLAVE_NOTIFY_NOW);
> -
> -			slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n");
> -
> -			bond_miimon_link_change(bond, slave, BOND_LINK_DOWN);
> -
> -			if (slave == rcu_access_pointer(bond->curr_active_slave))
> +			if (bond_miimon_slave_down(bond, slave))
>  				do_failover = true;
> -
>  			continue;
>  
>  		case BOND_LINK_FAIL:
> @@ -2919,6 +2935,12 @@ static void bond_mii_monitor(struct work_struct *work)
>  
>  		if (commit) {
>  			bond_for_each_slave(bond, slave, iter) {
> +				/* UP state is committed by bond_miimon_commit()
> +				 * after the speed and duplex check, so that it
> +				 * can still see the previous link state.
> +				 */
> +				if (slave->link_new_state == BOND_LINK_UP)
> +					continue;
>  				bond_commit_link_state(slave,
>  						       BOND_SLAVE_NOTIFY_LATER);
>  			}
> -- 
> 2.43.0
> 

This version looks good to me. Thanks!

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <auKmQjdgtgZTTbmJ@fedora>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353119-linux-kernel-netdev=dewy.ru
References: <20261028104758.299129-1-timur.stukan.linux@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353119-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] bonding: fix missing down path on speed/duplex
 failure after FAIL->UP
Date: Thu, 29 Oct 2026 09:49:54 +0800
Organization: Usenet Network
Message-ID: <auKmQjdgtgZTTbmJ@fedora>
References: <20261028104758.299129-1-timur.stukan.linux@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1913567"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:KBy2cWhx0t+3CqLYgud2sN2VVfM= sha256:rLcUls9QxeSqFben0p8oiJn3UeuILw6OzEu1xGmDPhg=
	sha1:lz7V33JFsVtwijvZAqdXCd84YhA= sha256:ke4Npb+JB9kN4EvzkZSasqr6/hmucexTKutL2hm1zvU=
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 61DF4125C51; Thu, 29 Oct 2026 04:50:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=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 HRFbq-0gLa4g;
	Thu, 29 Oct 2026 04:50:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353119-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 9E9D1125C44; Thu, 29 Oct 2026 04:50:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id E42032650C; Thu, 29 Oct 2026 01:50:11 +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=1793238611;
	b=zfWHsmp08eZT7Bfm0/ema0n7UbZUk0HGz7xaE6tPb3355Nvq9vmzeS/R7V79zQ+rT7/h
	 siuqFQfYUqsSAAuccye0R0Fwbc6QiKdwTiU4wG0naG/uukXsRYZ560uSZIzMD7gxiu+pg
	 pZAcKFHBqL/qkt5m+a0kZcx/NYtz2tWrAxiC1bmhJm27bzjHEiO1rBdaX4/YLmU8//9uw
	 0M1FC/sDnUcAYfPU0yGIIWr/0OfYWdwtL3Qw2p1h/+5oslIDFCLdQwz4oXwXXw8EUe2Hf
	 S1YSSd89Qg4N+/Dc0wiu//mH5L2Bm47vDJ64CqC4yLoH21l/EysMfm5BmoC8sAd0iMg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793238611;
	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=sZZBpevcS9exsrSP43oxzD9Zj4JnPGWquROSBgpnzbg=;
	b=J/YLuZOdsJ8TKskkE0AtzuhrlFdKuZZdO/1FVaHwC6WwfETZMXi0+p/H8AWjDxpjIVDa
	 4H52me3ifmV1OhyE1sj0L9IW0toPCzjAoJKlo1zB8KqrtppoNol6Lo4p/s8U8MWF9r6hf
	 0PYTv2jy8YacHpb/sbcDZ/ExnauTXxdceHbIPDmiiP/shlKzJ5JrAz/msqNiXe5JjJZKq
	 8OSXKnv04ys4a/7lnvEoTB3pPNW/R5tsbfbF/HXg2YrLFq+urOBqSHpU/5hfGwq2q5116
	 p3U6cy/byZ65ueAuKxIAEdF/UaBYOyk+x+j98lXnG6K3XNSjPGnM98jVZc+v6il40Yg==
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=i2PpjwMG;
	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 29BC5606A322;
	Thu, 29 Oct 2026 01:50:11 +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=i2PpjwMG
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793238610;
	b=gdhtVcwfzuiNo26/UMqiO8d4aWx4iWpoh5u2EODLcbqqf+jWtfDL2yQEzXdd8OutVAui
	 tRqFeQWVXXpRJFT9EIt4f/WjgjzP0OJf1QRo/DjjcIqKcNHWHEIFhf9nIZHhE2EMnGC5v
	 yMowVeLnWUVO+lS/N86NfbelXfNUDEeAbJsAGFFs859X74Sc/TmKHon87aCa+kC3z4iNQ
	 BkZ8hVLu40gqMWYfCNdb+QKKxgubYJqhQiNQo2+b5aERkTUGDX14/s0nSgGDBwqn2FBHt
	 2k4GNvmU2F+1K74RXKxOIjDWJcAtgG8iwQaKOgptsyzoJIyEJFSP0zl9T2sGpIlERKQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793238610;
	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=sZZBpevcS9exsrSP43oxzD9Zj4JnPGWquROSBgpnzbg=;
	b=OPKkOA2FTzWbKdflaD1grNZD4YYW9eXrj2fUM+LPqr0LG/rBhIQu7uEQEQwQ5WKeEB/V
	 I3eWDdP9DNz2sxOZ8jvp01qyCoDm/z05ECDlEuytTjep7YMCCTz+eji8Ylt/17Ty7aTUa
	 M0SJrVj+MLX9JrCjeY2xZRg0AQDlrqGhYziaAQ4TjwoAqFA0mpzpIZpTsBbriVThyl6AL
	 DlUkVmjWqKmHfARGxiAoq2Wy2BiZBwICzHM8JW1i/Yo9XjgyJtLzY7Mj4U2R0J5YxDIyT
	 mf+fRECQx5PKRzor6+TTq1TS9j5nGFQffPAbFOGa+nmFBhSMy9RVoYwzgsUrl2BgShA==
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=i2PpjwMG;
	arc=none smtp.remote-ip=95.215.58.41
X-Received: from mta1.migadu.com (out-41.mta1.migadu.com [95.215.58.41])
	(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 63F8C606A31C
	for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 01:50:08 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63F8C606A31C
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=wiwG9ToSHOr3fU9gexOdX6gsXe0wZeBMdWaLYbFvjxg=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793238607; v=1; x=1793843407;
 b=i2PpjwMGANasD+VZYAYK94V7QCR7LRDLjAV2Q8SKpZP4qIOWs2Xm1vqSoUrz00vSqZXeL7k5
 bd/qb0C0CgD4IlH3+sifllXvYcsiuunjastTA/x4zVk6YP+HbVv7DB9nupQxCe7ouDUvB8HTizO
 re3P07ox+QfrAw4CWcd8HRM4=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id f4dc8f7a90c5f8c2;
	Thu, 29 Oct 2026 01:50:07 +0000
X-Mizu-Trace-ID: f4dc8f7a90c5f8c2
X-Migadu-Flow: FLOW_OUT
X-Cc: netdev@vger.kernel.org, Nikolay Aleksandrov <razor@blackwall.org>,
	Fernando Fernandez Mancera <fmancera@suse.de>,
	Jay Vosburgh <jv@jvosburgh.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@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: <20261028104758.299129-1-timur.stukan.linux@gmail.com>