From: Hangbin Liu <hangbin.liu@linux.dev>
To: Timur Stukan <timur.stukan.linux@gmail.com>
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
Subject: Re: [PATCH net] bonding: fix missing down path on speed/duplex failure after FAIL->UP
Date: Tue, 27 Oct 2026 08:50:17 +0800 [thread overview]
Message-ID: <at_1RnSinpG5t7bZ@fedora> (raw)
In-Reply-To: <CAF+_u5Bo7_GySpNLv00omfAtKD++5DJYgriSO_=rwzNT7vrfyg@mail.gmail.com>
On Mon, Oct 26, 2026 at 12:20:37PM +0200, Timur Stukan wrote:
> On Mon, 26 Oct 2026 at 02:56, Hangbin Liu <hangbin.liu@linux.dev> wrote:
> >
> > On Fri, Oct 23, 2026 at 03:35:57PM +0300, Timur Stukan wrote:
> > > On Fri, 23 Oct 2026 at 10:48, Hangbin Liu <hangbin.liu@linux.dev> wrote:
> > >
> > > > > 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?
> > >
> > >
> > > Hi Hangbin,
> > >
> > > Thanks for the review and the suggestion.
> > >
> > > A detached device is one way to get there, but it does not cover all
> > > the ways to hit this bug. In particular, it does not cover the case i
> > > reproduced: during inspect both link_state and netif_device_present()
> > > are true, but the carrier is lost after inspect and before commit, so
> > > reading speed/duplex fails in commit.
> >
> > Hi Timur,
> >
> > Thanks for the explain, but the same question to this patch. How do you
> > make sure the carrier is not lost during bond_miimon_inspect() and
> > this slave->link_prev_state setting?
> >
> > Thanks
> > Hangbin
>
> Hi Hangbin,
>
> Thanks for the question. To answer directly: there is no way to make
> sure the carrier is not lost between bond_miimon_inspect() and setting
> link_prev_state, but the fix does not need that.
>
> Let's split the miimon logic with this patch into 3 steps, executed in
> this order:
> - bond_miimon_inspect() - carrier is checked here and new state is proposed.
> - setting slave->link_prev_state - just a copy of slave->link, it is
> not read from the carrier.
> - bond_miimon_commit(), case UP - speed/duplex check.
>
> And there is the case where downdelay is set and active slave flaps,
> so it is currently in FAIL. Possible scenarios:
> a) The carrier is present during inspect, so bond_miimon_inspect()
> proposes link_new_state as UP for active slave. Then the carrier is
> lost somewhere between bond_miimon_inspect() and bond_miimon_commit().
> It does not matter whether this happens before (your question) or
> after setting link_prev_state, it is set to FAIL anyway. Then in
> bond_miimon_commit() in case UP, speed/duplex check fails because
> carrier is lost and because link_prev_state is FAIL, the active slave
> goes through a regular down path with failover.
> b) The carrier is lost before bond_miimon_inspect(), so UP is not
> proposed at all, and after downdelay the slave goes DOWN through the
> same regular down path.
> c) The carrier is lost after bond_miimon_commit(), so the slave is
> already UP. On the next miimon tick bond_miimon_inspect() proposes
> FAIL and then it follows the same path as in b).
>
> So slave->link_prev_state is not affected by carrier changes between
> inspect and commit, that is just a copy of slave->link, needed to do
> the right thing in bond_miimon_commit() if the speed/duplex check
> fails (e.g. because the carrier is lost).
>
> The same applies to the approach without link_prev_state I proposed to
> Jay, since there slave->link itself still holds the previous state in
> bond_miimon_commit().
Ah, yes. I miss-read that. The bond_propose_link_state() only set the
link_new_state to up. The slave->link state is still BOND_LINK_FAIL.
Thanks
Hangbin
next prev parent reply other threads:[~2026-10-27 0:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 10:38 [PATCH net] bonding: fix missing down path on speed/duplex failure after FAIL->UP Timur Stukan
2026-10-23 7:48 ` Hangbin Liu
2026-10-23 12:35 ` Timur Stukan
2026-10-26 0:56 ` Hangbin Liu
2026-10-26 10:20 ` Timur Stukan
2026-10-27 0:50 ` Hangbin Liu [this message]
2026-10-23 13:24 ` Jay Vosburgh
2026-10-25 12:07 ` Timur Stukan
2026-10-26 11:01 ` netdev-bot+sashiko
2026-10-26 13:17 ` Timur Stukan
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=at_1RnSinpG5t7bZ@fedora \
--to=hangbin.liu@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fmancera@suse.de \
--cc=horms@kernel.org \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=timur.stukan.linux@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.