Skip to content

Commit de77ecd

Browse files
Mahesh Bandewardavem330
authored andcommitted
bonding: improve link-status update in mii-monitoring
The primary issue is that mii-inspect phase updates link-state and expects changes to be committed during the mii-commit phase. After the inspect phase if it fails to acquire rtnl-mutex, the commit phase (bond_mii_commit) doesn't get to run. This partially updated state stays and makes the internal-state inconsistent. e.g. setup bond0 => slaves: eth1, eth2 eth1 goes DOWN -> UP mii_monitor() mii-inspect() bond_set_slave_link_state(eth1, UP, DontNotify) rtnl_trylock() <- fails! Next mii-monitor round eth1: No change mii_monitor() mii-inspect() eth1->link == current-status (ethtool_ops->get_link) no-change-detected End result: eth1: Link = BOND_LINK_UP Speed = 0xfffff [SpeedUnknown] Duplex = 0xff [DuplexUnknown] This doesn't always happen but for some unlucky machines in a large set of machines it creates problems. The fix for this is to avoid making changes during inspect phase and postpone them until acquiring the rtnl-mutex / invoking commit phase. Signed-off-by: Mahesh Bandewar <maheshb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f307668 commit de77ecd

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎drivers/net/bonding/bond_main.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,8 +2033,7 @@ static int bond_miimon_inspect(struct bonding *bond)
20332033
if (link_state)
20342034
continue;
20352035

2036-
bond_set_slave_link_state(slave, BOND_LINK_FAIL,
2037-
BOND_SLAVE_NOTIFY_LATER);
2036+
bond_propose_link_state(slave, BOND_LINK_FAIL);
20382037
slave->delay = bond->params.downdelay;
20392038
if (slave->delay) {
20402039
netdev_info(bond->dev, "link status down for %sinterface %s, disabling it in %d ms\n",
@@ -2049,8 +2048,7 @@ static int bond_miimon_inspect(struct bonding *bond)
20492048
case BOND_LINK_FAIL:
20502049
if (link_state) {
20512050
/* recovered before downdelay expired */
2052-
bond_set_slave_link_state(slave, BOND_LINK_UP,
2053-
BOND_SLAVE_NOTIFY_LATER);
2051+
bond_propose_link_state(slave, BOND_LINK_UP);
20542052
slave->last_link_up = jiffies;
20552053
netdev_info(bond->dev, "link status up again after %d ms for interface %s\n",
20562054
(bond->params.downdelay - slave->delay) *
@@ -2072,8 +2070,7 @@ static int bond_miimon_inspect(struct bonding *bond)
20722070
if (!link_state)
20732071
continue;
20742072

2075-
bond_set_slave_link_state(slave, BOND_LINK_BACK,
2076-
BOND_SLAVE_NOTIFY_LATER);
2073+
bond_propose_link_state(slave, BOND_LINK_BACK);
20772074
slave->delay = bond->params.updelay;
20782075

20792076
if (slave->delay) {
@@ -2086,9 +2083,7 @@ static int bond_miimon_inspect(struct bonding *bond)
20862083
/*FALLTHRU*/
20872084
case BOND_LINK_BACK:
20882085
if (!link_state) {
2089-
bond_set_slave_link_state(slave,
2090-
BOND_LINK_DOWN,
2091-
BOND_SLAVE_NOTIFY_LATER);
2086+
bond_propose_link_state(slave, BOND_LINK_DOWN);
20922087
netdev_info(bond->dev, "link status down again after %d ms for interface %s\n",
20932088
(bond->params.updelay - slave->delay) *
20942089
bond->params.miimon,
@@ -2225,6 +2220,8 @@ static void bond_mii_monitor(struct work_struct *work)
22252220
mii_work.work);
22262221
bool should_notify_peers = false;
22272222
unsigned long delay;
2223+
struct slave *slave;
2224+
struct list_head *iter;
22282225

22292226
delay = msecs_to_jiffies(bond->params.miimon);
22302227

@@ -2245,6 +2242,9 @@ static void bond_mii_monitor(struct work_struct *work)
22452242
goto re_arm;
22462243
}
22472244

2245+
bond_for_each_slave(bond, slave, iter) {
2246+
bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER);
2247+
}
22482248
bond_miimon_commit(bond);
22492249

22502250
rtnl_unlock(); /* might sleep, hold no other locks */

0 commit comments

Comments
 (0)