2 * IPV6 GSO/GRO offload support
3 * Linux INET implementation
5 * Copyright (C) 2016 secunet Security Networks AG
6 * Author: Steffen Klassert <steffen.klassert@secunet.com>
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.
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>
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>
31 #include <linux/icmpv6.h>
33 static struct sk_buff
**esp6_gro_receive(struct sk_buff
**head
,
36 int offset
= skb_gro_offset(skb
);
37 struct xfrm_offload
*xo
;
43 skb_pull(skb
, offset
);
45 if ((err
= xfrm_parse_spi(skb
, IPPROTO_ESP
, &spi
, &seq
)) != 0)
48 err
= secpath_set(skb
);
52 if (skb
->sp
->len
== XFRM_MAX_DEPTH
)
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
);
61 skb
->sp
->xvec
[skb
->sp
->len
++] = x
;
64 xo
= xfrm_offload(skb
);
69 xo
->flags
|= XFRM_GRO
;
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
;
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);
80 return ERR_PTR(-EINPROGRESS
);
82 skb_push(skb
, offset
);
83 NAPI_GRO_CB(skb
)->same_flow
= 0;
84 NAPI_GRO_CB(skb
)->flush
= 1;
89 static const struct net_offload esp6_offload
= {
91 .gro_receive
= esp6_gro_receive
,
95 static int __init
esp6_offload_init(void)
97 return inet6_add_offload(&esp6_offload
, IPPROTO_ESP
);
100 static void __exit
esp6_offload_exit(void)
102 inet6_del_offload(&esp6_offload
, IPPROTO_ESP
);
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>");