diff mbox series

[NET-PREV,41/51] bridge: Make port to have the same nd_lock as bridge

Message ID 174265457731.356712.7862799948363989386.stgit@pro.pro (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Kill rtnl_lock using fine-grained nd_lock | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply, async

Commit Message

Kirill Tkhai March 22, 2025, 2:42 p.m. UTC
Signed-off-by: Kirill Tkhai <tkhai@ya.ru>
---
 net/bridge/br_ioctl.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index f213ed108361..b4b0cc6ac08b 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -85,6 +85,7 @@  static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
 static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 {
 	struct net *net = dev_net(br->dev);
+	struct nd_lock *nd_lock, *nd_lock2;
 	struct net_device *dev;
 	int ret;
 
@@ -95,9 +96,12 @@  static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 	if (dev == NULL)
 		return -EINVAL;
 
-	if (isadd)
+	if (isadd) {
+		double_lock_netdev(br->dev, &nd_lock, dev, &nd_lock2);
+		nd_lock_transfer_devices(&nd_lock, &nd_lock2);
 		ret = br_add_if(br, dev, NULL);
-	else
+		double_unlock_netdev(nd_lock, nd_lock2);
+	} else
 		ret = br_del_if(br, dev);
 
 	return ret;