Skip to content

Commit 4ca0d9a

Browse files
jarodwilsondavem330
authored andcommitted
bonding: show saner speed for broadcast mode
Broadcast mode bonds transmit a copy of all traffic simultaneously out of all interfaces, so the "speed" of the bond isn't really the aggregate of all interfaces, but rather, the speed of the slowest active interface. Also, the type of the speed field is u32, not unsigned long, so adjust that accordingly, as required to make min() function here without complaining about mismatching types. Fixes: bb5b052 ("bond: add support to read speed and duplex via ethtool") CC: Jay Vosburgh <[email protected]> CC: Veaceslav Falico <[email protected]> CC: Andy Gospodarek <[email protected]> CC: "David S. Miller" <[email protected]> CC: [email protected] Acked-by: Jay Vosburgh <[email protected]> Signed-off-by: Jarod Wilson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10a3b7c commit 4ca0d9a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4552,13 +4552,23 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
45524552
return ret;
45534553
}
45544554

4555+
static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed)
4556+
{
4557+
if (speed == 0 || speed == SPEED_UNKNOWN)
4558+
speed = slave->speed;
4559+
else
4560+
speed = min(speed, slave->speed);
4561+
4562+
return speed;
4563+
}
4564+
45554565
static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
45564566
struct ethtool_link_ksettings *cmd)
45574567
{
45584568
struct bonding *bond = netdev_priv(bond_dev);
4559-
unsigned long speed = 0;
45604569
struct list_head *iter;
45614570
struct slave *slave;
4571+
u32 speed = 0;
45624572

45634573
cmd->base.duplex = DUPLEX_UNKNOWN;
45644574
cmd->base.port = PORT_OTHER;
@@ -4570,8 +4580,13 @@ static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
45704580
*/
45714581
bond_for_each_slave(bond, slave, iter) {
45724582
if (bond_slave_can_tx(slave)) {
4573-
if (slave->speed != SPEED_UNKNOWN)
4574-
speed += slave->speed;
4583+
if (slave->speed != SPEED_UNKNOWN) {
4584+
if (BOND_MODE(bond) == BOND_MODE_BROADCAST)
4585+
speed = bond_mode_bcast_speed(slave,
4586+
speed);
4587+
else
4588+
speed += slave->speed;
4589+
}
45754590
if (cmd->base.duplex == DUPLEX_UNKNOWN &&
45764591
slave->duplex != DUPLEX_UNKNOWN)
45774592
cmd->base.duplex = slave->duplex;

0 commit comments

Comments
 (0)