]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
esp6: Support RX checksum with crypto offload
authorIlan Tayari <ilant@mellanox.com>
Tue, 1 Aug 2017 09:49:05 +0000 (12:49 +0300)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 2 Aug 2017 09:00:15 +0000 (11:00 +0200)
Keep the device's reported ip_summed indication in case crypto
was offloaded by the device. Subtract the csum values of the
stripped parts (esp header+iv, esp trailer+auth_data) to keep
value correct.

Note: CHECKSUM_COMPLETE should be indicated only if skb->csum
has the post-decryption offload csum value.

Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Ilan Tayari <ilant@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv6/esp6.c
net/ipv6/esp6_offload.c

index 9ed35473dcb53bd6ae52f8f86e1558410bbcd7b6..0ca1db62e3815a559cd26e037287107e649318ba 100644 (file)
@@ -470,7 +470,8 @@ int esp6_input_done2(struct sk_buff *skb, int err)
        int hlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead);
        int elen = skb->len - hlen;
        int hdr_len = skb_network_header_len(skb);
-       int padlen;
+       int padlen, trimlen;
+       __wsum csumdiff;
        u8 nexthdr[2];
 
        if (!xo || (xo && !(xo->flags & CRYPTO_DONE)))
@@ -492,8 +493,15 @@ int esp6_input_done2(struct sk_buff *skb, int err)
 
        /* ... check padding bits here. Silly. :-) */
 
-       pskb_trim(skb, skb->len - alen - padlen - 2);
-       __skb_pull(skb, hlen);
+       trimlen = alen + padlen + 2;
+       if (skb->ip_summed == CHECKSUM_COMPLETE) {
+               csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
+               skb->csum = csum_block_sub(skb->csum, csumdiff,
+                                          skb->len - trimlen);
+       }
+       pskb_trim(skb, skb->len - trimlen);
+
+       skb_pull_rcsum(skb, hlen);
        if (x->props.mode == XFRM_MODE_TUNNEL)
                skb_reset_transport_header(skb);
        else
index f02f131f6435a967de395b9a7069051c93a039d7..eec3add177fef84b5cfe111ec43843bca629479b 100644 (file)
@@ -209,11 +209,13 @@ static struct sk_buff *esp6_gso_segment(struct sk_buff *skb,
 static int esp6_input_tail(struct xfrm_state *x, struct sk_buff *skb)
 {
        struct crypto_aead *aead = x->data;
+       struct xfrm_offload *xo = xfrm_offload(skb);
 
        if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead)))
                return -EINVAL;
 
-       skb->ip_summed = CHECKSUM_NONE;
+       if (!(xo->flags & CRYPTO_DONE))
+               skb->ip_summed = CHECKSUM_NONE;
 
        return esp6_input_done2(skb, 0);
 }