linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bonding: force carrier update when releasing slave
@ 2022-02-16 14:18 Zhang Changzhong
  2022-02-17 18:40 ` Jay Vosburgh
  2022-02-17 19:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zhang Changzhong @ 2022-02-16 14:18 UTC (permalink / raw)
  To: Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, David S. Miller,
	Jakub Kicinski, Jeff Garzik
  Cc: Zhang Changzhong, netdev, linux-kernel

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(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bonding: force carrier update when releasing slave
  2022-02-16 14:18 [PATCH net] bonding: force carrier update when releasing slave Zhang Changzhong
@ 2022-02-17 18:40 ` Jay Vosburgh
  2022-02-17 19:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jay Vosburgh @ 2022-02-17 18:40 UTC (permalink / raw)
  To: Zhang Changzhong
  Cc: Veaceslav Falico, Andy Gospodarek, David S. Miller,
	Jakub Kicinski, Jeff Garzik, netdev, linux-kernel

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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bonding: force carrier update when releasing slave
  2022-02-16 14:18 [PATCH net] bonding: force carrier update when releasing slave Zhang Changzhong
  2022-02-17 18:40 ` Jay Vosburgh
@ 2022-02-17 19:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-17 19:00 UTC (permalink / raw)
  To: Zhang Changzhong
  Cc: j.vosburgh, vfalico, andy, davem, kuba, jeff, netdev, linux-kernel

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-17 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 14:18 [PATCH net] bonding: force carrier update when releasing slave Zhang Changzhong
2022-02-17 18:40 ` Jay Vosburgh
2022-02-17 19:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).