Skip to content

Commit c166080

Browse files
shayshyiPaolo Abeni
authored andcommitted
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 <[email protected]> Signed-off-by: Mark Bloch <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent e24431a commit c166080

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3268,7 +3268,7 @@ int call_netdevice_notifiers_info(unsigned long val,
32683268
#define for_each_netdev_continue_rcu(net, d) \
32693269
list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
32703270
#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) \
32723272
if (netdev_master_upper_dev_get_rcu(slave) == (bond))
32733273
#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
32743274

0 commit comments

Comments
 (0)