[PATCH NET-PREV 40/51] openvswitch: Make ports share nd_lock of master device

Kirill Tkhai posted 51 patches 9 months ago
[PATCH NET-PREV 40/51] openvswitch: Make ports share nd_lock of master device
Posted by Kirill Tkhai 9 months ago
Signed-off-by: Kirill Tkhai <tkhai@ya.ru>
---
 net/openvswitch/vport-netdev.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c
index 91a11067e458..e629fc3c1442 100644
--- a/net/openvswitch/vport-netdev.c
+++ b/net/openvswitch/vport-netdev.c
@@ -75,6 +75,7 @@ static struct net_device *get_dpdev(const struct datapath *dp)
 
 struct vport *ovs_netdev_link(struct vport *vport, const char *name)
 {
+	struct nd_lock *nd_lock, *nd_lock2;
 	int err;
 
 	vport->dev = dev_get_by_name(ovs_dp_get_net(vport->dp), name);
@@ -99,9 +100,14 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
 	}
 
 	rtnl_lock();
+	double_lock_netdev(vport->dev, &nd_lock, get_dpdev(vport->dp), &nd_lock2);
+	nd_lock_transfer_devices(&nd_lock, &nd_lock2);
+
 	err = netdev_master_upper_dev_link(vport->dev,
 					   get_dpdev(vport->dp),
 					   NULL, NULL, NULL);
+	double_unlock_netdev(nd_lock, nd_lock2);
+
 	if (err)
 		goto error_unlock;