Article View: linux.kernel.netdev
Article #6710Re: [PATCH net] bonding: fix missing down path on speed/duplex failure after FAIL->UP
From: Hangbin Liu
Date: Fri, 23 Oct 2026 07:48
Date: Fri, 23 Oct 2026 07:48
175 lines
15579 bytes
15579 bytes
On Thu, Oct 22, 2026 at 01:38:21PM +0300, 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 recording the link state before the miimon commit and when
> the speed/duplex update fails for a slave coming from BOND_LINK_FAIL,
> taking it through the regular down path, including failover. The
> BOND_LINK_BACK case keeps 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:
> sizeof(struct slave) grows from 608 to 616 bytes due to padding.
> I kept link_prev_state next to link/link_new_state for readability;
> it can be moved into the hole after 'delay' if preferred.
>
> drivers/net/bonding/bond_main.c | 53 ++++++++++++++++++++++-----------
> include/net/bonding.h | 1 +
> 2 files changed, 36 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 09aa45d71fab..602ad697a9c2 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;
Hmm, this issue only happens when link_state is on
netif_running(slave->dev) && netif_carrier_ok(slave->dev);
while !netif_device_present. Should we set the link up when device detached?
> 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_prev_state == 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,7 @@ static void bond_mii_monitor(struct work_struct *work)
>
> if (commit) {
> bond_for_each_slave(bond, slave, iter) {
> + slave->link_prev_state = slave->link;
> bond_commit_link_state(slave,
> BOND_SLAVE_NOTIFY_LATER);
> }
> diff --git a/include/net/bonding.h b/include/net/bonding.h
> index 598d56b1bc97..b2b102946fe1 100644
> --- a/include/net/bonding.h
> +++ b/include/net/bonding.h
> @@ -165,6 +165,7 @@ struct slave {
> unsigned long target_last_arp_rx[BOND_MAX_ARP_TARGETS];
> s8 link; /* one of BOND_LINK_XXXX */
> s8 link_new_state; /* one of BOND_LINK_XXXX */
> + s8 link_prev_state; /* one of BOND_LINK_XXXX */
> u8 backup:1, /* indicates backup slave. Value corresponds with
> BOND_STATE_ACTIVE and BOND_STATE_BACKUP */
> inactive:1, /* indicates inactive slave */
> --
> 2.43.0
>
Checking slave->inactive is not enough when user sets all_slaves_active, so
I'm not opposed to adding a new link state. The code looks good to me.
But let's see others opinion.
Thanks
Hangbin
Technical Details
Message-ID:
<atsRW-aYHeB-cEgi@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-350951-linux-kernel-netdev=dewy.ruReferences:
<20261022103821.89552-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-350951-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] bonding: fix missing down path on speed/duplex failure after FAIL->UP Date: Fri, 23 Oct 2026 15:48:43 +0800 Organization: Usenet Network Message-ID: <atsRW-aYHeB-cEgi@fedora> References: <20261022103821.89552-1-timur.stukan.linux@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="442159"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:29uwXdvgThMn3Gs7Kp4AemAvxxo= sha256:cvOjlKg1UZhf1VRVk99DymBDCdmLUSr3G7Hu+zMkrC4= sha1:RZ8aRsN4tK8nS3B8mVMPDugm+SM= sha256:xJ7qu1Nt2hP51tENe/XhSeauYDoXDPPr6JMEnoU2tZg= 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 6E3FE111428; Fri, 23 Oct 2026 10:50:59 +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 xbSV9nMkYuQZ; Fri, 23 Oct 2026 10:50:54 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350951-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id E10CA111409; Fri, 23 Oct 2026 10:50:44 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 802B52A93C; Fri, 23 Oct 2026 07:49:03 +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=1792741734; b=FCYRZikicm4euXfnf8fv/RmzS6Yy/28gnPCZa2Hx3b134rR11IqPVbK0DkN4oYPKB6Vz /DNXZsjNyAqQ3GbsWub/HBLodJrPxLj5boM1qqTeEvYe4OteuVjZAW04xPJdrK+l2We16 eqaALBWIwjiKO6BA9VyHIdeaxRnWYELYB/5tf/l+F+Sfct8rtiXRAZ9IcxUhsbVar7q3s /TxSlu/A9oKswGN+hqpUyvxu7mf57rJwq/HlPbLGCBb0ojGca9VlR9Nzo8hbB3ar+E/NK +hjiOJPTpmRn813WqxwJQ06F/E+gS5J3d35OhF7UkSfDhq2EKb5vxz+yOTEDmMvs23g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792741734; 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=bfPE62FlLN/egcHfCSCBNP5XR/zJLO5pn7FeFIIyaXI=; b=ZhSbcuF05tWy2EE8/2lozS3TL6H/TgbsNIfTDFXWypYh5EybheBXrfQbFOcWdWtC6vbK GayU5VBQtAjCnRhcqAnDthnKBs7v7n+FwoF9FgdLfbkFh3wIqUXq++REvOrPNSpVePEvy vUfrXo8zFBru5A9FalDfbfzVlfvmae6Om3RF8DRV62AXNfBgcDe908njNd4Q9jUjOiYXK mo711znPSw+26ta4ddLrPJW5ZzC85fN/wD9zSfS7eOJ7nfhTFllhAiHKacf0FlDTm89gv PPKVia+/ZjFWRMMA03QIqRnoAMxQ8yh0rmC/qdsIr8ULH4tkHFbIBgHyBK7tDuiWxIQ== 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=okFutr01; 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 7807960A260D; Fri, 23 Oct 2026 07:48:54 +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=okFutr01 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.192 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792741733; b=15b9gKpQR0DjBNVFfGN9lEv61xG0x1IpelDivzOQlAOSIz/m3YVyLH5K/3hIn+5HS1Wh 0YAAeqJwumnpoSkvzwxvaVpP0uLZY5Um7hxTN9obDunYbk7gjCqOLX/vyJkabnKJheMdm kx85uirQZVkKG3+AssnXjo2Le17Ml3oysw/X5Tn3oo6Pd4H1NIiEMZlGvksWybGOF4ZWC KseldWDKrwmRbGMQp4ehQkzXamnmA1ar2aNF60TrB34IVi1Ytt5bvpdl3ukogLZHBWTON 3WIuwVT+Qbrv8wd4Dnfh1kIR1BZK8/DzvLnc6Zjp+2E+6Jmrwpi4Qd9xwx8OoYhOlPg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792741733; 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=bfPE62FlLN/egcHfCSCBNP5XR/zJLO5pn7FeFIIyaXI=; b=iGPZT1sb64LspFE+BbWZXafgmnHdvAnUIDduczwCAqeGQlrkTLuNLf1XzVJXAMrZiuzL 4D6u3LCWANHATXjaHhk98fNe7P8aBgd11qX9+JHTsaRGdAGSTkTiFCpcyDEEXRsdJ6FgG IW5hQunIh8idnWMzFr30uIBT5pXKTfHH0k2KiGaymGn3oKk6Q+Hdbr5u89Bvt47Fmb+Bt YGaSX2FQS6IT1XSjjzrbD0oaYB/mSliY6Iqmq/N0fmpUtL4mI344Q6p3AhQThhcZYziRo jgWSQYcVMgM52c0BSarw6II14tb964sNVMz7Ydyb8muqePuULSk4dgHDOL340yI4LFQ== 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=okFutr01; arc=none smtp.remote-ip=95.215.58.192 X-Received: from mta1.migadu.com (out-192.mta1.migadu.com [95.215.58.192]) (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 B9CA4606A338 for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 07:48:52 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B9CA4606A338 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=kQHMs3C0Pwk4XnxoCJ6mEPI/OsvCcahIVnwyiihsmKQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792741730; v=1; x=1793346530; b=okFutr01VmDqzjcHjd4gE3d4xUWGajTJ2qfI1UDc9JhVJHwe+I0VcqkLtlOG/pFTyRnmlMgi mFqitA+O6TmsFXgnOQJOGqtyNKQMwkerhDz/Z8LuoVJmMTz+cXime6c1MBTMUY1HTyWu0WXpASD BXjZBIk+sD2dDKKyxt5glzPU= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta12.migadu.com with ESMTPS id a5aea95c2b268905; Fri, 23 Oct 2026 07:48:50 +0000 X-Mizu-Trace-ID: a5aea95c2b268905 X-Migadu-Flow: FLOW_OUT X-Cc: netdev@vger.kernel.org, Hangbin Liu <liuhangbin@gmail.com>, 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>, Nikolay Aleksandrov <razor@blackwall.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, 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: <20261022103821.89552-1-timur.stukan.linux@gmail.com>