tcp: Call skb_gro_checksum_validate
authorTom Herbert <therbert@google.com>
Fri, 22 Aug 2014 20:34:30 +0000 (13:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Aug 2014 01:09:24 +0000 (18:09 -0700)
In tcp[64]_gro_receive call skb_gro_checksum_validate to validate TCP
checksum in the gro context.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_offload.c
net/ipv6/tcpv6_offload.c

index bc1b83cb8309f5d4737d7751e9542823e044b587..72912533a191ba0335bc8c0d3ec3817d5af45f23 100644 (file)
@@ -288,35 +288,14 @@ static int tcp_v4_gso_send_check(struct sk_buff *skb)
 
 static struct sk_buff **tcp4_gro_receive(struct sk_buff **head, struct sk_buff *skb)
 {
-       /* Use the IP hdr immediately proceeding for this transport */
-       const struct iphdr *iph = skb_gro_network_header(skb);
-       __wsum wsum;
-
        /* Don't bother verifying checksum if we're going to flush anyway. */
-       if (NAPI_GRO_CB(skb)->flush)
-               goto skip_csum;
-
-       wsum = NAPI_GRO_CB(skb)->csum;
-
-       switch (skb->ip_summed) {
-       case CHECKSUM_NONE:
-               wsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb),
-                                   0);
-
-               /* fall through */
-
-       case CHECKSUM_COMPLETE:
-               if (!tcp_v4_check(skb_gro_len(skb), iph->saddr, iph->daddr,
-                                 wsum)) {
-                       skb->ip_summed = CHECKSUM_UNNECESSARY;
-                       break;
-               }
-
+       if (!NAPI_GRO_CB(skb)->flush &&
+           skb_gro_checksum_validate(skb, IPPROTO_TCP,
+                                     inet_gro_compute_pseudo)) {
                NAPI_GRO_CB(skb)->flush = 1;
                return NULL;
        }
 
-skip_csum:
        return tcp_gro_receive(head, skb);
 }
 
index 01b0ff9a0c2c00d6734537254e2150edcbcb64d7..dbb3d9262bf66837a10e6ecc764dbcd0ea327264 100644 (file)
@@ -35,34 +35,14 @@ static int tcp_v6_gso_send_check(struct sk_buff *skb)
 static struct sk_buff **tcp6_gro_receive(struct sk_buff **head,
                                         struct sk_buff *skb)
 {
-       const struct ipv6hdr *iph = skb_gro_network_header(skb);
-       __wsum wsum;
-
        /* Don't bother verifying checksum if we're going to flush anyway. */
-       if (NAPI_GRO_CB(skb)->flush)
-               goto skip_csum;
-
-       wsum = NAPI_GRO_CB(skb)->csum;
-
-       switch (skb->ip_summed) {
-       case CHECKSUM_NONE:
-               wsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb),
-                                   wsum);
-
-               /* fall through */
-
-       case CHECKSUM_COMPLETE:
-               if (!tcp_v6_check(skb_gro_len(skb), &iph->saddr, &iph->daddr,
-                                 wsum)) {
-                       skb->ip_summed = CHECKSUM_UNNECESSARY;
-                       break;
-               }
-
+       if (!NAPI_GRO_CB(skb)->flush &&
+           skb_gro_checksum_validate(skb, IPPROTO_TCP,
+                                     ip6_gro_compute_pseudo)) {
                NAPI_GRO_CB(skb)->flush = 1;
                return NULL;
        }
 
-skip_csum:
        return tcp_gro_receive(head, skb);
 }