netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Pravin Shelar <pshelar@nicira.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH net] vxlan: add necessary locking on device removal
Date: Sat, 13 Jul 2013 10:18:18 -0700	[thread overview]
Message-ID: <20130713101818.0d4fa8e0@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <CALnjE+rO7Npw=rU_VL7T1pPDdFBKXB3KpVbpf_jQ0cJ6+ah1nQ@mail.gmail.com>

The socket management is now done in workqueue (outside of RTNL)
and protected by vn->sock_lock. There were two possible bugs, first
the vxlan device was removed from the VNI hash table per socket without
holding lock. And there was a race when device is created and the workqueue
could run after deletion.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/drivers/net/vxlan.c	2013-07-08 16:31:50.080744429 -0700
+++ b/drivers/net/vxlan.c	2013-07-10 20:15:47.337653899 -0700
@@ -1767,9 +1767,15 @@ static int vxlan_newlink(struct net *net
 
 static void vxlan_dellink(struct net_device *dev, struct list_head *head)
 {
+	struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
 	struct vxlan_dev *vxlan = netdev_priv(dev);
 
+	flush_workqueue(vxlan_wq);
+
+	spin_lock(&vn->sock_lock);
 	hlist_del_rcu(&vxlan->hlist);
+	spin_unlock(&vn->sock_lock);
+
 	list_del(&vxlan->next);
 	unregister_netdevice_queue(dev, head);
 }

  parent reply	other threads:[~2013-07-13 17:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Stephen Hemminger [this message]
2013-07-13 19:21       ` [PATCH net] vxlan: add necessary locking on device removal 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130713101818.0d4fa8e0@nehalam.linuxnetplumber.net \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).