Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: Look for bonding slaves in the bond's network namespace

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>
Link: https://patch.msgid.link/20250513081922.525716-1-mbloch@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Shay Drory and committed by
Paolo Abeni
c1660800 e24431a2

+1 -1
+1 -1
include/linux/netdevice.h
··· 3268 3268 #define for_each_netdev_continue_rcu(net, d) \ 3269 3269 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list) 3270 3270 #define for_each_netdev_in_bond_rcu(bond, slave) \ 3271 - for_each_netdev_rcu(&init_net, slave) \ 3271 + for_each_netdev_rcu(dev_net_rcu(bond), slave) \ 3272 3272 if (netdev_master_upper_dev_get_rcu(slave) == (bond)) 3273 3273 #define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) 3274 3274