vxlan: stability patches
Subsystems (2)
cover vxlan: stability patches
No change to the content of any of these patches,
the only change is the order of which patches are in which bundle and the base (these are for -net).
Stephen Hemminger (3):
vxlan: fix race between flush and incoming learning
vxlan: only migrate dynamic FDB entries
vxlan: handle skb_clone failure
drivers/net/vxlan.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/3 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 CPU2vxlan_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.
--- drivers/net/vxlan.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/vxlan.c +9 -7
@@ -571,7 +571,6 @@ static void vxlan_snoop(struct net_device *dev, {struct vxlan_dev *vxlan =netdev_priv (dev);struct vxlan_fdb *f; -int err; f =vxlan_find_mac (vxlan, src_mac);if (likely (f)) {
@@ -588,12 +587,15 @@ static void vxlan_snoop(struct net_device *dev, }else {/* learned new entry */ spin_lock (&vxlan->hash_lock); - err =vxlan_fdb_create (vxlan, src_mac, src_ip, -NUD_REACHABLE , -NLM_F_EXCL |NLM_F_CREATE , - vxlan->dst_port, - vxlan->default_dst.remote_vni, -0 ,NTF_SELF ); + +/* close off race between vxlan_flush and incoming packets */ +if (netif_running (dev)) +vxlan_fdb_create (vxlan, src_mac, src_ip, +NUD_REACHABLE , +NLM_F_EXCL |NLM_F_CREATE , + vxlan->dst_port, + vxlan->default_dst.remote_vni, +0 ,NTF_SELF );spin_unlock (&vxlan->hash_lock); } }
Signature · 1 line
1.7.10.4
PATCH 2/3 vxlan: only migrate dynamic FDB entries
In reply to Stephen HemmingerOnly migrate dynamic forwarding table entries, don't modify static entries. If packet received from incorrect source IP address assume it is an imposter and drop it.
This patch applies only to -net, a different patch would be needed for earlier kernels since the NTF_SELF flag was introduced with 3.10.
--- drivers/net/vxlan.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/vxlan.c +12 -4
@@ -565,8 +565,9 @@ skip:/* Watch incoming packets to learn mapping between Ethernet address * and Tunnel endpoint. +* Return true if packet is bogus and should be droppped. */ -static void vxlan_snoop (struct net_device *dev, +static bool vxlan_snoop (struct net_device *dev,__be32 src_ip,const u8 *src_mac) {struct vxlan_dev *vxlan =netdev_priv (dev);
@@ -575,7 +576,11 @@ static void vxlan_snoop(struct net_device *dev, f =vxlan_find_mac (vxlan, src_mac);if (likely (f)) {if (likely (f->remote.remote_ip == src_ip)) -return ; +return false; + +/* Don't migrate static entries, drop packets */ +if (!(f->flags &NTF_SELF )) +return true;if (net_ratelimit ()) netdev_info(dev,
@@ -598,6 +603,8 @@ static void vxlan_snoop(struct net_device *dev, 0, NTF_SELF);spin_unlock (&vxlan->hash_lock); } + +return false; }
@@ -729,8 +736,9 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) vxlan->dev->dev_addr) == 0) goto drop; -if (vxlan->flags &VXLAN_F_LEARN ) -vxlan_snoop (skb->dev, oip->saddr,eth_hdr (skb)->h_source); +if ((vxlan->flags &VXLAN_F_LEARN ) && +vxlan_snoop (skb->dev, oip->saddr,eth_hdr (skb)->h_source)) + goto drop;__skb_tunnel_rx (skb, vxlan->dev);skb_reset_network_header (skb);
Signature · 1 line
1.7.10.4
PATCH 3/3 vxlan: handle skb_clone failure
In reply to Stephen HemmingerIf skb_clone fails if out of memory then just skip the fanout.
Problem was introduced in 3.10 with:
commit 6681712d67eef14c4ce793561c3231659153a320
Author: David Stevens <[email protected]>
Date: Fri Mar 15 04:35:51 2013 +0000
vxlan: generalize forwarding tables
--- drivers/net/vxlan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/vxlan.c +5 -3
@@ -1161,9 +1161,11 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)struct sk_buff *skb1; skb1 =skb_clone (skb,GFP_ATOMIC ); - rc1 =vxlan_xmit_one (skb1, dev, rdst, did_rsc); -if (rc ==NETDEV_TX_OK ) - rc = rc1; +if (skb1) { + rc1 =vxlan_xmit_one (skb1, dev, rdst, did_rsc); +if (rc ==NETDEV_TX_OK ) + rc = rc1; + } } rc1 =vxlan_xmit_one (skb, dev, rdst0, did_rsc);
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 17 Jun 2013 12:09:56 -0700
Quoted 3 lines
No change to the content of any of these patches,
the only change is the order of which patches are in which bundle and the base (these are for -net).
Series applied, thanks.