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

Kirill Tkhai posted 51 patches 9 months ago
[PATCH NET-PREV 41/51] bridge: Make port to have the same nd_lock as bridge
Posted by Kirill Tkhai 9 months ago
Signed-off-by: Kirill Tkhai <tkhai@ya.ru>
---
 net/bridge/br_ioctl.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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;