Commit 3bf74b1a authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

vxlan: fix race between flush and incoming learning

It is possible for a packet to arrive during vxlan_stop(), and
have a dynamic entry created. Close this by checking if device
is up.

 CPU1                             CPU2
vxlan_stop
  vxlan_flush
     hash_lock acquired
                                  vxlan_encap_recv
                                     vxlan_snoop
                                        waiting for hash_lock
     hash_lock relased
  vxlan_flush done
                                        hash_lock acquired
                                        vxlan_fdb_create

This is a day-one bug in vxlan goes back to 3.7.
Signed-off-by: default avatarStephen Hemminger <stephen@networkplumber.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8177a9d7
...@@ -571,7 +571,6 @@ static void vxlan_snoop(struct net_device *dev, ...@@ -571,7 +571,6 @@ static void vxlan_snoop(struct net_device *dev,
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_fdb *f; struct vxlan_fdb *f;
int err;
f = vxlan_find_mac(vxlan, src_mac); f = vxlan_find_mac(vxlan, src_mac);
if (likely(f)) { if (likely(f)) {
...@@ -588,7 +587,10 @@ static void vxlan_snoop(struct net_device *dev, ...@@ -588,7 +587,10 @@ static void vxlan_snoop(struct net_device *dev,
} else { } else {
/* learned new entry */ /* learned new entry */
spin_lock(&vxlan->hash_lock); spin_lock(&vxlan->hash_lock);
err = vxlan_fdb_create(vxlan, src_mac, src_ip,
/* close off race between vxlan_flush and incoming packets */
if (netif_running(dev))
vxlan_fdb_create(vxlan, src_mac, src_ip,
NUD_REACHABLE, NUD_REACHABLE,
NLM_F_EXCL|NLM_F_CREATE, NLM_F_EXCL|NLM_F_CREATE,
vxlan->dst_port, vxlan->dst_port,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment