diff mbox series

[net] bonding: force carrier update when releasing slave

Message ID 1645021088-38370-1-git-send-email-zhangchangzhong@huawei.com (mailing list archive)
State Accepted
Commit a6ab75cec1e461f8a35559054c146c21428430b8
Delegated to: Netdev Maintainers
Headers show
Series [net] bonding: force carrier update when releasing slave | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Zhang Changzhong Feb. 16, 2022, 2:18 p.m. UTC
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: ff59c4563a8d ("[PATCH] bonding: support carrier state for master")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
 drivers/net/bonding/bond_main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Jay Vosburgh Feb. 17, 2022, 6:40 p.m. UTC | #1
Zhang Changzhong <zhangchangzhong@huawei.com> wrote:

>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: ff59c4563a8d ("[PATCH] bonding: support carrier state for master")
>Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>

Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>


>---
> drivers/net/bonding/bond_main.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 238b56d..aebeb46 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -2379,10 +2379,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();
>-- 
>2.9.5
>
patchwork-bot+netdevbpf@kernel.org Feb. 17, 2022, 7 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 16 Feb 2022 22:18:08 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] bonding: force carrier update when releasing slave
    https://git.kernel.org/netdev/net/c/a6ab75cec1e4

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 238b56d..aebeb46 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2379,10 +2379,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();