All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jay Vosburgh <jv@jvosburgh.net>
To: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Weiping Pan <wpan@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 net] bonding: only set speed/duplex to unknown, if getting speed failed
Date: Tue, 03 Feb 2026 10:34:48 -0800	[thread overview]
Message-ID: <4098146.1770143688@famine> (raw)
In-Reply-To: <20260203141153.51581-1-tbogendoerfer@suse.de>

Thomas Bogendoerfer <tbogendoerfer@suse.de> wrote:

>bond_update_speed_duplex() first set speed/duplex to unknown and
>then asks slave driver for current speed/duplex. Since getting
>speed/duplex might take longer there is a race, where this false state
>is visible by /proc/net/bonding. With commit 691b2bf14946 ("bonding:
> update port speed when getting bond speed") this race gets more visible,
>if user space is calling ethtool on a regular base.
>
>Fix this by only setting speed/duplex to unknown, if link speed is
>really unknown/unusable.
>
>Fixes: 98f41f694f46 ("bonding:update speed/duplex for NETDEV_CHANGE")
>Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>

Acked-by: Jay Vosburgh <jv@jvosburgh.net>

	I think this Fixes tag is fine, it's far enough back in time to
be effectively all stable releases.  The actual change in the patch is
obviously correct, as well.

	-J

>---
>v2: corrected fixes tag
>v1: https://lore.kernel.org/all/20260130111904.144024-1-tbogendoerfer@suse.de/
>
> drivers/net/bonding/bond_main.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index e7caf400a59c..4cdf89b21ca0 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -791,26 +791,29 @@ static int bond_update_speed_duplex(struct slave *slave)
> 	struct ethtool_link_ksettings ecmd;
> 	int res;
> 
>-	slave->speed = SPEED_UNKNOWN;
>-	slave->duplex = DUPLEX_UNKNOWN;
>-
> 	res = __ethtool_get_link_ksettings(slave_dev, &ecmd);
> 	if (res < 0)
>-		return 1;
>+		goto speed_duplex_unknown;
> 	if (ecmd.base.speed == 0 || ecmd.base.speed == ((__u32)-1))
>-		return 1;
>+		goto speed_duplex_unknown;
> 	switch (ecmd.base.duplex) {
> 	case DUPLEX_FULL:
> 	case DUPLEX_HALF:
> 		break;
> 	default:
>-		return 1;
>+		goto speed_duplex_unknown;
> 	}
> 
> 	slave->speed = ecmd.base.speed;
> 	slave->duplex = ecmd.base.duplex;
> 
> 	return 0;
>+
>+speed_duplex_unknown:
>+	slave->speed = SPEED_UNKNOWN;
>+	slave->duplex = DUPLEX_UNKNOWN;
>+
>+	return 1;
> }
> 
> const char *bond_slave_link_status(s8 link)
>-- 
>2.43.0
>

---
	-Jay Vosburgh, jv@jvosburgh.net

  reply	other threads:[~2026-02-03 18:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 14:11 [PATCH v2 net] bonding: only set speed/duplex to unknown, if getting speed failed Thomas Bogendoerfer
2026-02-03 18:34 ` Jay Vosburgh [this message]
2026-02-03 18:48 ` Nikolay Aleksandrov
2026-02-04  1:12 ` Hangbin Liu
2026-02-05 21:00 ` patchwork-bot+netdevbpf

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=4098146.1770143688@famine \
    --to=jv@jvosburgh.net \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tbogendoerfer@suse.de \
    --cc=wpan@redhat.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.