diff options
author | Tom Herbert <therbert@google.com> | 2014-05-07 19:52:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-08 23:47:50 -0400 |
commit | 0a80966b1043c3e2dc684140f155a3fded308660 (patch) | |
tree | 9f8742c79ed1c3bf8f79eee1c46ea4c073fc80a5 | |
parent | 39471ac8dde690bf944248e06bec32a4568cdd45 (diff) |
net: Verify UDP checksum before handoff to encap
Moving validation of UDP checksum to be done in UDP not encap layer.
Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/udp.c | 4 | ||||
-rw-r--r-- | net/ipv6/udp.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index f2d05d7be743..54ea0a3a48f1 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1495,6 +1495,10 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
1495 | if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) { | 1495 | if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) { |
1496 | int ret; | 1496 | int ret; |
1497 | 1497 | ||
1498 | /* Verify checksum before giving to encap */ | ||
1499 | if (udp_lib_checksum_complete(skb)) | ||
1500 | goto csum_error; | ||
1501 | |||
1498 | ret = encap_rcv(sk, skb); | 1502 | ret = encap_rcv(sk, skb); |
1499 | if (ret <= 0) { | 1503 | if (ret <= 0) { |
1500 | UDP_INC_STATS_BH(sock_net(sk), | 1504 | UDP_INC_STATS_BH(sock_net(sk), |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index fc2be63e32d5..7edf096867c4 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -634,6 +634,10 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
634 | if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) { | 634 | if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) { |
635 | int ret; | 635 | int ret; |
636 | 636 | ||
637 | /* Verify checksum before giving to encap */ | ||
638 | if (udp_lib_checksum_complete(skb)) | ||
639 | goto csum_error; | ||
640 | |||
637 | ret = encap_rcv(sk, skb); | 641 | ret = encap_rcv(sk, skb); |
638 | if (ret <= 0) { | 642 | if (ret <= 0) { |
639 | UDP_INC_STATS_BH(sock_net(sk), | 643 | UDP_INC_STATS_BH(sock_net(sk), |