linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: Look for bonding slaves in the bond's network namespace
@ 2025-05-13  8:19 Mark Bloch
  2025-05-15 11:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Bloch @ 2025-05-13  8:19 UTC (permalink / raw)
  To: Jay Vosburgh, David S . Miller, Jakub Kicinski, Paolo Abeni,
	Eric Dumazet, Andrew Lunn
  Cc: Tariq Toukan, netdev, linux-kernel, Shay Drory, Mark Bloch

From: Shay Drory <shayd@nvidia.com>

Update the for_each_netdev_in_bond_rcu macro to iterate through network
devices in the bond's network namespace instead of always using
init_net. This change is safe because:

1. **Bond-Slave Namespace Relationship**: A bond device and its slaves
   must reside in the same network namespace. The bond device's
   namespace is established at creation time and cannot change.

2. **Slave Movement Implications**: Any attempt to move a slave device
   to a different namespace automatically removes it from the bond, as
   per kernel networking stack rules.
   This maintains the invariant that slaves must exist in the same
   namespace as their bond.

This change is part of an effort to enable Link Aggregation (LAG) to
work properly inside custom network namespaces. Previously, the macro
would only find slave devices in the initial network namespace,
preventing proper bonding functionality in custom namespaces.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
---
 include/linux/netdevice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 773167508c82..d584faa2dc4b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3266,7 +3266,7 @@ int call_netdevice_notifiers_info(unsigned long val,
 #define for_each_netdev_continue_rcu(net, d)		\
 	list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
 #define for_each_netdev_in_bond_rcu(bond, slave)	\
-		for_each_netdev_rcu(&init_net, slave)	\
+		for_each_netdev_rcu(dev_net_rcu(bond), slave)	\
 			if (netdev_master_upper_dev_get_rcu(slave) == (bond))
 #define net_device_entry(lh)	list_entry(lh, struct net_device, dev_list)
 

base-commit: e39d14a760c039af0653e3df967e7525413924a0
-- 
2.34.1


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

* Re: [PATCH net-next] net: Look for bonding slaves in the bond's network namespace
  2025-05-13  8:19 [PATCH net-next] net: Look for bonding slaves in the bond's network namespace Mark Bloch
@ 2025-05-15 11:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-15 11:30 UTC (permalink / raw)
  To: Mark Bloch
  Cc: jv, davem, kuba, pabeni, edumazet, andrew+netdev, tariqt, netdev,
	linux-kernel, shayd

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 13 May 2025 11:19:22 +0300 you wrote:
> From: Shay Drory <shayd@nvidia.com>
> 
> Update the for_each_netdev_in_bond_rcu macro to iterate through network
> devices in the bond's network namespace instead of always using
> init_net. This change is safe because:
> 
> 1. **Bond-Slave Namespace Relationship**: A bond device and its slaves
>    must reside in the same network namespace. The bond device's
>    namespace is established at creation time and cannot change.
> 
> [...]

Here is the summary with links:
  - [net-next] net: Look for bonding slaves in the bond's network namespace
    https://git.kernel.org/netdev/net-next/c/c16608005ccb

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] 2+ messages in thread

end of thread, other threads:[~2025-05-15 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13  8:19 [PATCH net-next] net: Look for bonding slaves in the bond's network namespace Mark Bloch
2025-05-15 11:30 ` 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).