Skip to content

Commit

Permalink
bonding: force carrier update when releasing slave
Browse files Browse the repository at this point in the history
commit a6ab75c upstream.

In __bond_release_one(), bond_set_carrier() is only called when bond
device has no slave. Therefore, if we remove the up slave from a master
with two slaves and keep the down slave, the master will remain up.

Fix this by moving bond_set_carrier() out of if (!bond_has_slaves(bond))
statement.

Reproducer:
$ insmod bonding.ko mode=0 miimon=100 max_bonds=2
$ ifconfig bond0 up
$ ifenslave bond0 eth0 eth1
$ ifconfig eth0 down
$ ifenslave -d bond0 eth1
$ cat /proc/net/bonding/bond0

Fixes: ff59c45 ("[PATCH] bonding: support carrier state for master")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Link: https://lore.kernel.org/r/1645021088-38370-1-git-send-email-zhangchangzhong@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Zhang Changzhong authored and gregkh committed Feb 23, 2022
1 parent 8dec3c4 commit a0e004e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/net/bonding/bond_main.c
Expand Up @@ -2272,10 +2272,9 @@ static int __bond_release_one(struct net_device *bond_dev,
bond_select_active_slave(bond);
}

if (!bond_has_slaves(bond)) {
bond_set_carrier(bond);
bond_set_carrier(bond);
if (!bond_has_slaves(bond))
eth_hw_addr_random(bond_dev);
}

unblock_netpoll_tx();
synchronize_rcu();
Expand Down

0 comments on commit a0e004e

Please sign in to comment.