~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv6/esp6_offload.c

Version: ~ [ linux-5.12-rc7 ] ~ [ linux-5.11.13 ] ~ [ linux-5.10.29 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.111 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.186 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.230 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.266 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.266 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * IPV6 GSO/GRO offload support
  3  * Linux INET implementation
  4  *
  5  * Copyright (C) 2016 secunet Security Networks AG
  6  * Author: Steffen Klassert <steffen.klassert@secunet.com>
  7  *
  8  * This program is free software; you can redistribute it and/or modify it
  9  * under the terms and conditions of the GNU General Public License,
 10  * version 2, as published by the Free Software Foundation.
 11  *
 12  * ESP GRO support
 13  */
 14 
 15 #include <linux/skbuff.h>
 16 #include <linux/init.h>
 17 #include <net/protocol.h>
 18 #include <crypto/aead.h>
 19 #include <crypto/authenc.h>
 20 #include <linux/err.h>
 21 #include <linux/module.h>
 22 #include <net/ip.h>
 23 #include <net/xfrm.h>
 24 #include <net/esp.h>
 25 #include <linux/scatterlist.h>
 26 #include <linux/kernel.h>
 27 #include <linux/slab.h>
 28 #include <linux/spinlock.h>
 29 #include <net/ip6_route.h>
 30 #include <net/ipv6.h>
 31 #include <linux/icmpv6.h>
 32 
 33 static struct sk_buff **esp6_gro_receive(struct sk_buff **head,
 34                                          struct sk_buff *skb)
 35 {
 36         int offset = skb_gro_offset(skb);
 37         struct xfrm_offload *xo;
 38         struct xfrm_state *x;
 39         __be32 seq;
 40         __be32 spi;
 41         int err;
 42 
 43         skb_pull(skb, offset);
 44 
 45         if ((err = xfrm_parse_spi(skb, IPPROTO_ESP, &spi, &seq)) != 0)
 46                 goto out;
 47 
 48         err = secpath_set(skb);
 49         if (err)
 50                 goto out;
 51 
 52         if (skb->sp->len == XFRM_MAX_DEPTH)
 53                 goto out;
 54 
 55         x = xfrm_state_lookup(dev_net(skb->dev), skb->mark,
 56                               (xfrm_address_t *)&ipv6_hdr(skb)->daddr,
 57                               spi, IPPROTO_ESP, AF_INET6);
 58         if (!x)
 59                 goto out;
 60 
 61         skb->sp->xvec[skb->sp->len++] = x;
 62         skb->sp->olen++;
 63 
 64         xo = xfrm_offload(skb);
 65         if (!xo) {
 66                 xfrm_state_put(x);
 67                 goto out;
 68         }
 69         xo->flags |= XFRM_GRO;
 70 
 71         XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL;
 72         XFRM_SPI_SKB_CB(skb)->family = AF_INET6;
 73         XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr);
 74         XFRM_SPI_SKB_CB(skb)->seq = seq;
 75 
 76         /* We don't need to handle errors from xfrm_input, it does all
 77          * the error handling and frees the resources on error. */
 78         xfrm_input(skb, IPPROTO_ESP, spi, -2);
 79 
 80         return ERR_PTR(-EINPROGRESS);
 81 out:
 82         skb_push(skb, offset);
 83         NAPI_GRO_CB(skb)->same_flow = 0;
 84         NAPI_GRO_CB(skb)->flush = 1;
 85 
 86         return NULL;
 87 }
 88 
 89 static const struct net_offload esp6_offload = {
 90         .callbacks = {
 91                 .gro_receive = esp6_gro_receive,
 92         },
 93 };
 94 
 95 static int __init esp6_offload_init(void)
 96 {
 97         return inet6_add_offload(&esp6_offload, IPPROTO_ESP);
 98 }
 99 
100 static void __exit esp6_offload_exit(void)
101 {
102         inet6_del_offload(&esp6_offload, IPPROTO_ESP);
103 }
104 
105 module_init(esp6_offload_init);
106 module_exit(esp6_offload_exit);
107 MODULE_LICENSE("GPL");
108 MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
109 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp