netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] vxlan: Fix vs->vni_list locking.
@ 2013-07-10 22:04 Pravin B Shelar
  2013-07-10 22:58 ` Stephen Hemminger
  0 siblings, 1 reply; 13+ messages in thread
From: Pravin B Shelar @ 2013-07-10 22:04 UTC (permalink / raw)
  To: netdev; +Cc: stephen, Pravin B Shelar

Use rtnl lock to protect vs->vni_list updates.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 drivers/net/vxlan.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 227b54a..deca481 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -89,7 +89,7 @@ struct vxlan_sock {
 	struct work_struct del_work;
 	atomic_t	  refcnt;
 	struct socket	  *sock;
-	struct hlist_head vni_list[VNI_HASH_SIZE];
+	struct hlist_head vni_list[VNI_HASH_SIZE]; /* Protected by RTNL. */
 };
 
 /* per-network namespace private data for this module */
@@ -122,7 +122,7 @@ struct vxlan_fdb {
 
 /* Pseudo network device */
 struct vxlan_dev {
-	struct hlist_node hlist;	/* vni hash table */
+	struct hlist_node hlist;	/* vni hash table (vni_list) */
 	struct list_head  next;		/* vxlan's per namespace list */
 	struct vxlan_sock *vn_sock;	/* listening socket */
 	struct net_device *dev;
@@ -1644,16 +1644,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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-07-17 19:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-10 22:04 [PATCH net-next] vxlan: Fix vs->vni_list locking Pravin B Shelar
2013-07-10 22:58 ` Stephen Hemminger
2013-07-10 23:08   ` Pravin Shelar
2013-07-10 23:25     ` Stephen Hemminger
2013-07-11  2:55       ` David Miller
2013-07-13 17:18     ` [PATCH net] vxlan: add necessary locking on device removal Stephen Hemminger
2013-07-13 19:21       ` Pravin Shelar
2013-07-16 18:28         ` David Miller
2013-07-16 20:29           ` Pravin Shelar
2013-07-17  6:06             ` David Miller
2013-07-17 15:41               ` Pravin Shelar
2013-07-17 19:09                 ` David Miller
2013-07-17 19:51       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).