DORMANTno replies

[PATCH vxlan v2 2/8] vxlan: Fix vs->vni_list locking.

From: Pravin B Shelar <hidden>
Date: 2013-06-26 20:14:04
Subsystem: networking drivers, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Use rtnl lock to protect vs->vni_list updates.

Signed-off-by: Pravin B Shelar <redacted>
---
 drivers/net/vxlan.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 0ba1e7e..f658d39 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1321,13 +1321,16 @@ static int vxlan_init(struct net_device *dev)
 		/* If we have a socket with same port already, reuse it */
 		atomic_inc(&vs->refcnt);
 		vxlan->vn_sock = vs;
+		spin_unlock(&vn->sock_lock);
+		rtnl_lock();
 		hlist_add_head_rcu(&vxlan->hlist, vni_head(vs, vni));
+		rtnl_unlock();
 	} else {
+		spin_unlock(&vn->sock_lock);
 		/* otherwise make new socket outside of RTNL */
 		dev_hold(dev);
 		queue_work(vxlan_wq, &vxlan->sock_work);
 	}
-	spin_unlock(&vn->sock_lock);
 
 	return 0;
 }
@@ -1644,16 +1647,21 @@ static void vxlan_sock_work(struct work_struct *work)
 	if (ovs) {
 		atomic_inc(&ovs->refcnt);
 		vxlan->vn_sock = ovs;
-		hlist_add_head_rcu(&vxlan->hlist, vni_head(ovs, vni));
 		spin_unlock(&vn->sock_lock);
 
+		rtnl_lock();
+		hlist_add_head_rcu(&vxlan->hlist, vni_head(ovs, vni));
+		rtnl_unlock();
+
 		sk_release_kernel(nvs->sock->sk);
 		kfree(nvs);
 	} else {
 		vxlan->vn_sock = nvs;
 		hlist_add_head_rcu(&nvs->hlist, vs_head(net, port));
-		hlist_add_head_rcu(&vxlan->hlist, vni_head(nvs, vni));
 		spin_unlock(&vn->sock_lock);
+		rtnl_lock();
+		hlist_add_head_rcu(&vxlan->hlist, vni_head(nvs, vni));
+		rtnl_unlock();
 	}
 out:
 	dev_put(dev);
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help