aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstephen hemminger <stephen@networkplumber.org>2013-06-17 15:09:58 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-17 18:55:46 -0400
commit26a41ae604381c5cc0caf1c3261ca6b298b5fe69 (patch)
tree011b32f24b97a5f5d5aa1fb7b97c8583bd90d634
parent3bf74b1aecdce719f1445200d5db7dfee2297bba (diff)
vxlan: only migrate dynamic FDB entries
Only 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. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/vxlan.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 577a069a6dde..15a73ec42c64 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -565,8 +565,9 @@ skip:
565 565
566/* Watch incoming packets to learn mapping between Ethernet address 566/* Watch incoming packets to learn mapping between Ethernet address
567 * and Tunnel endpoint. 567 * and Tunnel endpoint.
568 * Return true if packet is bogus and should be droppped.
568 */ 569 */
569static void vxlan_snoop(struct net_device *dev, 570static bool vxlan_snoop(struct net_device *dev,
570 __be32 src_ip, const u8 *src_mac) 571 __be32 src_ip, const u8 *src_mac)
571{ 572{
572 struct vxlan_dev *vxlan = netdev_priv(dev); 573 struct vxlan_dev *vxlan = netdev_priv(dev);
@@ -575,7 +576,11 @@ static void vxlan_snoop(struct net_device *dev,
575 f = vxlan_find_mac(vxlan, src_mac); 576 f = vxlan_find_mac(vxlan, src_mac);
576 if (likely(f)) { 577 if (likely(f)) {
577 if (likely(f->remote.remote_ip == src_ip)) 578 if (likely(f->remote.remote_ip == src_ip))
578 return; 579 return false;
580
581 /* Don't migrate static entries, drop packets */
582 if (!(f->flags & NTF_SELF))
583 return true;
579 584
580 if (net_ratelimit()) 585 if (net_ratelimit())
581 netdev_info(dev, 586 netdev_info(dev,
@@ -598,6 +603,8 @@ static void vxlan_snoop(struct net_device *dev,
598 0, NTF_SELF); 603 0, NTF_SELF);
599 spin_unlock(&vxlan->hash_lock); 604 spin_unlock(&vxlan->hash_lock);
600 } 605 }
606
607 return false;
601} 608}
602 609
603 610
@@ -729,8 +736,9 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
729 vxlan->dev->dev_addr) == 0) 736 vxlan->dev->dev_addr) == 0)
730 goto drop; 737 goto drop;
731 738
732 if (vxlan->flags & VXLAN_F_LEARN) 739 if ((vxlan->flags & VXLAN_F_LEARN) &&
733 vxlan_snoop(skb->dev, oip->saddr, eth_hdr(skb)->h_source); 740 vxlan_snoop(skb->dev, oip->saddr, eth_hdr(skb)->h_source))
741 goto drop;
734 742
735 __skb_tunnel_rx(skb, vxlan->dev); 743 __skb_tunnel_rx(skb, vxlan->dev);
736 skb_reset_network_header(skb); 744 skb_reset_network_header(skb);