mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
bonding: only set speed/duplex to unknown, if getting speed failed
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 commit691b2bf149("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:98f41f694f("bonding:update speed/duplex for NETDEV_CHANGE") Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de> Acked-by: Jay Vosburgh <jv@jvosburgh.net> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://patch.msgid.link/20260203141153.51581-1-tbogendoerfer@suse.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
2d2d574309
commit
48dec8d88a
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user