Skip to content

Commit

Permalink
vxlan: add necessary locking on device removal
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Jul 17, 2013
1 parent f457082 commit fe5c356
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,9 +1767,15 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,

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);
}
Expand Down

0 comments on commit fe5c356

Please sign in to comment.