Skip to content

Commit 98f41f6

Browse files
Weiping Pandavem330
authored andcommitted
bonding:update speed/duplex for NETDEV_CHANGE
Zheng Liang(lzheng@redhat.com) found a bug that if we config bonding with arp monitor, sometimes bonding driver cannot get the speed and duplex from its slaves, it will assume them to be 100Mb/sec and Full, please see /proc/net/bonding/bond0. But there is no such problem when uses miimon. (Take igb for example) I find that the reason is that after dev_open() in bond_enslave(), bond_update_speed_duplex() will call igb_get_settings() , but in that function, it runs ethtool_cmd_speed_set(ecmd, -1); ecmd->duplex = -1; because igb get an error value of status. So even dev_open() is called, but the device is not really ready to get its settings. Maybe it is safe for us to call igb_get_settings() only after this message shows up, that is "igb: p4p1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX". So I prefer to update the speed and duplex for a slave when reseices NETDEV_CHANGE/NETDEV_UP event. Changelog V2: 1 remove the "fake 100/Full" logic in bond_update_speed_duplex(), set speed and duplex to -1 when it gets error value of speed and duplex. 2 delete the warning in bond_enslave() if bond_update_speed_duplex() returns error. 3 make bond_info_show_slave() handle bad values of speed and duplex. Signed-off-by: Weiping Pan <wpan@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent deede2f commit 98f41f6

2 files changed

Lines changed: 22 additions & 27 deletions

File tree

‎drivers/net/bonding/bond_main.c‎

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ static int bond_set_carrier(struct bonding *bond)
550550
/*
551551
* Get link speed and duplex from the slave's base driver
552552
* using ethtool. If for some reason the call fails or the
553-
* values are invalid, fake speed and duplex to 100/Full
553+
* values are invalid, set speed and duplex to -1,
554554
* and return error.
555555
*/
556556
static int bond_update_speed_duplex(struct slave *slave)
@@ -560,9 +560,8 @@ static int bond_update_speed_duplex(struct slave *slave)
560560
u32 slave_speed;
561561
int res;
562562

563-
/* Fake speed and duplex */
564-
slave->speed = SPEED_100;
565-
slave->duplex = DUPLEX_FULL;
563+
slave->speed = -1;
564+
slave->duplex = -1;
566565

567566
res = __ethtool_get_settings(slave_dev, &ecmd);
568567
if (res < 0)
@@ -1751,16 +1750,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
17511750
new_slave->link = BOND_LINK_DOWN;
17521751
}
17531752

1754-
if (bond_update_speed_duplex(new_slave) &&
1755-
(new_slave->link != BOND_LINK_DOWN)) {
1756-
pr_warning("%s: Warning: failed to get speed and duplex from %s, assumed to be 100Mb/sec and Full.\n",
1757-
bond_dev->name, new_slave->dev->name);
1758-
1759-
if (bond->params.mode == BOND_MODE_8023AD) {
1760-
pr_warning("%s: Warning: Operation of 802.3ad mode requires ETHTOOL support in base driver for proper aggregator selection.\n",
1761-
bond_dev->name);
1762-
}
1763-
}
1753+
bond_update_speed_duplex(new_slave);
17641754

17651755
if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) {
17661756
/* if there is a primary slave, remember it */
@@ -3220,6 +3210,7 @@ static int bond_slave_netdev_event(unsigned long event,
32203210
{
32213211
struct net_device *bond_dev = slave_dev->master;
32223212
struct bonding *bond = netdev_priv(bond_dev);
3213+
struct slave *slave = NULL;
32233214

32243215
switch (event) {
32253216
case NETDEV_UNREGISTER:
@@ -3230,20 +3221,16 @@ static int bond_slave_netdev_event(unsigned long event,
32303221
bond_release(bond_dev, slave_dev);
32313222
}
32323223
break;
3224+
case NETDEV_UP:
32333225
case NETDEV_CHANGE:
3234-
if (bond->params.mode == BOND_MODE_8023AD || bond_is_lb(bond)) {
3235-
struct slave *slave;
3226+
slave = bond_get_slave_by_dev(bond, slave_dev);
3227+
if (slave) {
3228+
u32 old_speed = slave->speed;
3229+
u8 old_duplex = slave->duplex;
32363230

3237-
slave = bond_get_slave_by_dev(bond, slave_dev);
3238-
if (slave) {
3239-
u32 old_speed = slave->speed;
3240-
u8 old_duplex = slave->duplex;
3241-
3242-
bond_update_speed_duplex(slave);
3243-
3244-
if (bond_is_lb(bond))
3245-
break;
3231+
bond_update_speed_duplex(slave);
32463232

3233+
if (bond->params.mode == BOND_MODE_8023AD) {
32473234
if (old_speed != slave->speed)
32483235
bond_3ad_adapter_speed_changed(slave);
32493236
if (old_duplex != slave->duplex)

‎drivers/net/bonding/bond_procfs.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,16 @@ static void bond_info_show_slave(struct seq_file *seq,
157157
seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
158158
seq_printf(seq, "MII Status: %s\n",
159159
(slave->link == BOND_LINK_UP) ? "up" : "down");
160-
seq_printf(seq, "Speed: %d Mbps\n", slave->speed);
161-
seq_printf(seq, "Duplex: %s\n", slave->duplex ? "full" : "half");
160+
if (slave->speed == -1)
161+
seq_printf(seq, "Speed: %s\n", "Unknown");
162+
else
163+
seq_printf(seq, "Speed: %d Mbps\n", slave->speed);
164+
165+
if (slave->duplex == -1)
166+
seq_printf(seq, "Duplex: %s\n", "Unknown");
167+
else
168+
seq_printf(seq, "Duplex: %s\n", slave->duplex ? "full" : "half");
169+
162170
seq_printf(seq, "Link Failure Count: %u\n",
163171
slave->link_failure_count);
164172

0 commit comments

Comments
 (0)