1 From foo@baz Fri Jun 17 11:18:18 PDT 2016
2 From: Hannes Frederic Sowa <hannes@stressinduktion.org>
3 Date: Thu, 19 May 2016 15:58:33 +0200
4 Subject: udp: prevent skbs lingering in tunnel socket queues
6 From: Hannes Frederic Sowa <hannes@stressinduktion.org>
8 [ Upstream commit e5aed006be918af163eb397e45aa5ea6cefd5e01 ]
10 In case we find a socket with encapsulation enabled we should call
11 the encap_recv function even if just a udp header without payload is
12 available. The callbacks are responsible for correctly verifying and
15 Also, in case the header validation fails for geneve and vxlan we
16 shouldn't put the skb back into the socket queue, no one will pick
17 them up there. Instead we can simply discard them in the respective
20 Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
21 Signed-off-by: David S. Miller <davem@davemloft.net>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 drivers/net/geneve.c | 10 +++-------
25 drivers/net/vxlan.c | 10 ++--------
28 4 files changed, 7 insertions(+), 17 deletions(-)
30 --- a/drivers/net/geneve.c
31 +++ b/drivers/net/geneve.c
32 @@ -310,15 +310,15 @@ static int geneve_udp_encap_recv(struct
34 /* Need Geneve and inner Ethernet header to be present */
35 if (unlikely(!pskb_may_pull(skb, GENEVE_BASE_HLEN)))
39 /* Return packets with reserved bits set */
40 geneveh = geneve_hdr(skb);
41 if (unlikely(geneveh->ver != GENEVE_VER))
45 if (unlikely(geneveh->proto_type != htons(ETH_P_TEB)))
49 opts_len = geneveh->opt_len * 4;
50 if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len,
51 @@ -336,10 +336,6 @@ drop:
52 /* Consume bad packet */
57 - /* Let the UDP layer deal with the skb */
61 static struct socket *geneve_create_sock(struct net *net, bool ipv6,
62 --- a/drivers/net/vxlan.c
63 +++ b/drivers/net/vxlan.c
64 @@ -1254,7 +1254,7 @@ static int vxlan_udp_encap_recv(struct s
66 /* Need Vxlan and inner Ethernet header to be present */
67 if (!pskb_may_pull(skb, VXLAN_HLEN))
71 vxh = (struct vxlanhdr *)(udp_hdr(skb) + 1);
72 flags = ntohl(vxh->vx_flags);
73 @@ -1344,13 +1344,7 @@ drop:
75 netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
76 ntohl(vxh->vx_flags), ntohl(vxh->vx_vni));
80 - dst_release((struct dst_entry *)tun_dst);
82 - /* Return non vxlan pkt */
87 static int arp_reduce(struct net_device *dev, struct sk_buff *skb)
90 @@ -1531,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, s
92 /* if we're overly short, let UDP handle it */
93 encap_rcv = ACCESS_ONCE(up->encap_rcv);
94 - if (skb->len > sizeof(struct udphdr) && encap_rcv) {
98 /* Verify checksum before giving to encap */
101 @@ -647,7 +647,7 @@ int udpv6_queue_rcv_skb(struct sock *sk,
103 /* if we're overly short, let UDP handle it */
104 encap_rcv = ACCESS_ONCE(up->encap_rcv);
105 - if (skb->len > sizeof(struct udphdr) && encap_rcv) {
109 /* Verify checksum before giving to encap */