netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: bonding: update the slave array for broadcast mode
@ 2025-10-15 12:58 Tonghao Zhang
  2025-10-16  5:49 ` Jiri Slaby
  2025-10-16  5:51 ` Hangbin Liu
  0 siblings, 2 replies; 4+ messages in thread
From: Tonghao Zhang @ 2025-10-15 12:58 UTC (permalink / raw)
  To: netdev
  Cc: Tonghao Zhang, Jay Vosburgh, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jonathan Corbet,
	Andrew Lunn, Nikolay Aleksandrov, Hangbin Liu, Jiri Slaby, stable

This patch fixes ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad").
Before this commit, on the broadcast mode, all devices were traversed using the
bond_for_each_slave_rcu. This patch supports traversing devices by using all_slaves.
Therefore, we need to update the slave array when enslave or release salve.

Fixes: ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad")
Cc: Jay Vosburgh <jv@jvosburgh.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
---
 drivers/net/bonding/bond_main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 17c7542be6a5..2d6883296e32 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2384,7 +2384,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 		unblock_netpoll_tx();
 	}
 
-	if (bond_mode_can_use_xmit_hash(bond))
+	/* broadcast mode uses the all_slaves to loop through slaves. */
+	if (bond_mode_can_use_xmit_hash(bond) ||
+	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
 		bond_update_slave_arr(bond, NULL);
 
 	if (!slave_dev->netdev_ops->ndo_bpf ||
@@ -2560,7 +2562,8 @@ static int __bond_release_one(struct net_device *bond_dev,
 
 	bond_upper_dev_unlink(bond, slave);
 
-	if (bond_mode_can_use_xmit_hash(bond))
+	if (bond_mode_can_use_xmit_hash(bond) ||
+	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
 		bond_update_slave_arr(bond, slave);
 
 	slave_info(bond_dev, slave_dev, "Releasing %s interface\n",
-- 
2.34.1


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

* Re: [PATCH] net: bonding: update the slave array for broadcast mode
  2025-10-15 12:58 [PATCH] net: bonding: update the slave array for broadcast mode Tonghao Zhang
@ 2025-10-16  5:49 ` Jiri Slaby
  2025-10-16  5:51 ` Hangbin Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2025-10-16  5:49 UTC (permalink / raw)
  To: Tonghao Zhang, netdev
  Cc: Jay Vosburgh, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jonathan Corbet, Andrew Lunn,
	Nikolay Aleksandrov, Hangbin Liu, stable

On 15. 10. 25, 14:58, Tonghao Zhang wrote:
> This patch fixes ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad").
> Before this commit, on the broadcast mode, all devices were traversed using the
> bond_for_each_slave_rcu. This patch supports traversing devices by using all_slaves.
> Therefore, we need to update the slave array when enslave or release salve.
> 
> Fixes: ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad")
> Cc: Jay Vosburgh <jv@jvosburgh.net>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Simon Horman <horms@kernel.org>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> Cc: Hangbin Liu <liuhangbin@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>

Reported-by: Jiri Slaby <jirislaby@kernel.org>
Tested-by: Jiri Slaby <jirislaby@kernel.org>
Link: 
https://lore.kernel.org/all/a97e6e1e-81bc-4a79-8352-9e4794b0d2ca@kernel.org/

Thanks.

> Cc: <stable@vger.kernel.org>
> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
> ---
>   drivers/net/bonding/bond_main.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 17c7542be6a5..2d6883296e32 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2384,7 +2384,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>   		unblock_netpoll_tx();
>   	}
>   
> -	if (bond_mode_can_use_xmit_hash(bond))
> +	/* broadcast mode uses the all_slaves to loop through slaves. */
> +	if (bond_mode_can_use_xmit_hash(bond) ||
> +	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
>   		bond_update_slave_arr(bond, NULL);
>   
>   	if (!slave_dev->netdev_ops->ndo_bpf ||
> @@ -2560,7 +2562,8 @@ static int __bond_release_one(struct net_device *bond_dev,
>   
>   	bond_upper_dev_unlink(bond, slave);
>   
> -	if (bond_mode_can_use_xmit_hash(bond))
> +	if (bond_mode_can_use_xmit_hash(bond) ||
> +	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
>   		bond_update_slave_arr(bond, slave);
>   
>   	slave_info(bond_dev, slave_dev, "Releasing %s interface\n",


-- 
js
suse labs

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

* Re: [PATCH] net: bonding: update the slave array for broadcast mode
  2025-10-15 12:58 [PATCH] net: bonding: update the slave array for broadcast mode Tonghao Zhang
  2025-10-16  5:49 ` Jiri Slaby
@ 2025-10-16  5:51 ` Hangbin Liu
  2025-10-16 12:56   ` Tonghao Zhang
  1 sibling, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2025-10-16  5:51 UTC (permalink / raw)
  To: Tonghao Zhang
  Cc: netdev, Jay Vosburgh, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jonathan Corbet,
	Andrew Lunn, Nikolay Aleksandrov, Jiri Slaby, stable

Hi Tonghao,

Please add the target repo in the subject. e.g.

[PATCH net] net: bonding: update the slave array for broadcast mode

The patch looks good to me.

On Wed, Oct 15, 2025 at 08:58:08PM +0800, Tonghao Zhang wrote:
> This patch fixes ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad").
> Before this commit, on the broadcast mode, all devices were traversed using the
> bond_for_each_slave_rcu. This patch supports traversing devices by using all_slaves.
> Therefore, we need to update the slave array when enslave or release salve.
> 
> Fixes: ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad")
> Cc: Jay Vosburgh <jv@jvosburgh.net>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Simon Horman <horms@kernel.org>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> Cc: Hangbin Liu <liuhangbin@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
> ---
>  drivers/net/bonding/bond_main.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 17c7542be6a5..2d6883296e32 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2384,7 +2384,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>  		unblock_netpoll_tx();
>  	}
>  
> -	if (bond_mode_can_use_xmit_hash(bond))
> +	/* broadcast mode uses the all_slaves to loop through slaves. */
> +	if (bond_mode_can_use_xmit_hash(bond) ||
> +	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
>  		bond_update_slave_arr(bond, NULL);
>  
>  	if (!slave_dev->netdev_ops->ndo_bpf ||
> @@ -2560,7 +2562,8 @@ static int __bond_release_one(struct net_device *bond_dev,
>  
>  	bond_upper_dev_unlink(bond, slave);
>  
> -	if (bond_mode_can_use_xmit_hash(bond))
> +	if (bond_mode_can_use_xmit_hash(bond) ||
> +	    BOND_MODE(bond) == BOND_MODE_BROADCAST)
>  		bond_update_slave_arr(bond, slave);
>  
>  	slave_info(bond_dev, slave_dev, "Releasing %s interface\n",
> -- 
> 2.34.1
> 

Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>

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

* Re: [PATCH] net: bonding: update the slave array for broadcast mode
  2025-10-16  5:51 ` Hangbin Liu
@ 2025-10-16 12:56   ` Tonghao Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Tonghao Zhang @ 2025-10-16 12:56 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: netdev, Jay Vosburgh, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jonathan Corbet,
	Andrew Lunn, Nikolay Aleksandrov, Jiri Slaby, stable



> On Oct 16, 2025, at 13:51, Hangbin Liu <liuhangbin@gmail.com> wrote:
> 
> Hi Tonghao,
> 
> Please add the target repo in the subject. e.g.
> 
> [PATCH net] net: bonding: update the slave array for broadcast mode
V2 is post with target repo and fix typo in comment.
Thanks.
> 
> The patch looks good to me.
> 
> On Wed, Oct 15, 2025 at 08:58:08PM +0800, Tonghao Zhang wrote:
>> This patch fixes ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad").
>> Before this commit, on the broadcast mode, all devices were traversed using the
>> bond_for_each_slave_rcu. This patch supports traversing devices by using all_slaves.
>> Therefore, we need to update the slave array when enslave or release salve.
>> 
>> Fixes: ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad")
>> Cc: Jay Vosburgh <jv@jvosburgh.net>
>> Cc: "David S. Miller" <davem@davemloft.net>
>> Cc: Eric Dumazet <edumazet@google.com>
>> Cc: Jakub Kicinski <kuba@kernel.org>
>> Cc: Paolo Abeni <pabeni@redhat.com>
>> Cc: Simon Horman <horms@kernel.org>
>> Cc: Jonathan Corbet <corbet@lwn.net>
>> Cc: Andrew Lunn <andrew+netdev@lunn.ch>
>> Cc: Nikolay Aleksandrov <razor@blackwall.org>
>> Cc: Hangbin Liu <liuhangbin@gmail.com>
>> Cc: Jiri Slaby <jirislaby@kernel.org>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
>> ---
>> drivers/net/bonding/bond_main.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 17c7542be6a5..2d6883296e32 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -2384,7 +2384,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>> unblock_netpoll_tx();
>> }
>> 
>> - if (bond_mode_can_use_xmit_hash(bond))
>> + /* broadcast mode uses the all_slaves to loop through slaves. */
>> + if (bond_mode_can_use_xmit_hash(bond) ||
>> +    BOND_MODE(bond) == BOND_MODE_BROADCAST)
>> bond_update_slave_arr(bond, NULL);
>> 
>> if (!slave_dev->netdev_ops->ndo_bpf ||
>> @@ -2560,7 +2562,8 @@ static int __bond_release_one(struct net_device *bond_dev,
>> 
>> bond_upper_dev_unlink(bond, slave);
>> 
>> - if (bond_mode_can_use_xmit_hash(bond))
>> + if (bond_mode_can_use_xmit_hash(bond) ||
>> +    BOND_MODE(bond) == BOND_MODE_BROADCAST)
>> bond_update_slave_arr(bond, slave);
>> 
>> slave_info(bond_dev, slave_dev, "Releasing %s interface\n",
>> -- 
>> 2.34.1
>> 
> 
> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
> 


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

end of thread, other threads:[~2025-10-16 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 12:58 [PATCH] net: bonding: update the slave array for broadcast mode Tonghao Zhang
2025-10-16  5:49 ` Jiri Slaby
2025-10-16  5:51 ` Hangbin Liu
2025-10-16 12:56   ` Tonghao Zhang

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