Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IPV6 GSO/GRO offload support |
| 3 | * Linux INET6 implementation |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version |
| 8 | * 2 of the License, or (at your option) any later version. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/socket.h> |
| 13 | #include <linux/netdevice.h> |
| 14 | #include <linux/skbuff.h> |
Vlad Yasevich | c6b641a | 2012-11-15 08:49:22 +0000 | [diff] [blame] | 15 | #include <linux/printk.h> |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 16 | |
| 17 | #include <net/protocol.h> |
| 18 | #include <net/ipv6.h> |
| 19 | |
| 20 | #include "ip6_offload.h" |
| 21 | |
| 22 | static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) |
| 23 | { |
| 24 | const struct net_offload *ops = NULL; |
| 25 | |
| 26 | for (;;) { |
| 27 | struct ipv6_opt_hdr *opth; |
| 28 | int len; |
| 29 | |
| 30 | if (proto != NEXTHDR_HOP) { |
| 31 | ops = rcu_dereference(inet6_offloads[proto]); |
| 32 | |
| 33 | if (unlikely(!ops)) |
| 34 | break; |
| 35 | |
| 36 | if (!(ops->flags & INET6_PROTO_GSO_EXTHDR)) |
| 37 | break; |
| 38 | } |
| 39 | |
| 40 | if (unlikely(!pskb_may_pull(skb, 8))) |
| 41 | break; |
| 42 | |
| 43 | opth = (void *)skb->data; |
| 44 | len = ipv6_optlen(opth); |
| 45 | |
| 46 | if (unlikely(!pskb_may_pull(skb, len))) |
| 47 | break; |
| 48 | |
Li RongQing | fc6fb41 | 2014-10-18 17:27:42 +0800 | [diff] [blame] | 49 | opth = (void *)skb->data; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 50 | proto = opth->nexthdr; |
| 51 | __skb_pull(skb, len); |
| 52 | } |
| 53 | |
| 54 | return proto; |
| 55 | } |
| 56 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 57 | static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, |
| 58 | netdev_features_t features) |
| 59 | { |
| 60 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
| 61 | struct ipv6hdr *ipv6h; |
| 62 | const struct net_offload *ops; |
| 63 | int proto; |
| 64 | struct frag_hdr *fptr; |
| 65 | unsigned int unfrag_ip6hlen; |
Alexander Duyck | 802ab55 | 2016-04-10 21:45:03 -0400 | [diff] [blame^] | 66 | unsigned int payload_len; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 67 | u8 *prevhdr; |
| 68 | int offset = 0; |
Hannes Frederic Sowa | 91a48a2 | 2014-02-24 00:48:05 +0100 | [diff] [blame] | 69 | bool encap, udpfrag; |
Eric Dumazet | d3e5e00 | 2013-10-20 20:47:29 -0700 | [diff] [blame] | 70 | int nhoff; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 71 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 72 | if (unlikely(skb_shinfo(skb)->gso_type & |
Alexander Duyck | b6fef4c | 2014-11-21 19:37:09 -0800 | [diff] [blame] | 73 | ~(SKB_GSO_TCPV4 | |
| 74 | SKB_GSO_UDP | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 75 | SKB_GSO_DODGY | |
| 76 | SKB_GSO_TCP_ECN | |
Alexander Duyck | cbc53e0 | 2016-04-10 21:44:51 -0400 | [diff] [blame] | 77 | SKB_GSO_TCP_FIXEDID | |
| 78 | SKB_GSO_TCPV6 | |
Pravin B Shelar | 68c3316 | 2013-02-14 14:02:41 +0000 | [diff] [blame] | 79 | SKB_GSO_GRE | |
Tom Herbert | 4749c09 | 2014-06-04 17:20:23 -0700 | [diff] [blame] | 80 | SKB_GSO_GRE_CSUM | |
Eric Dumazet | cb32f51 | 2013-10-19 11:42:57 -0700 | [diff] [blame] | 81 | SKB_GSO_IPIP | |
Eric Dumazet | 61c1db7 | 2013-10-20 20:47:30 -0700 | [diff] [blame] | 82 | SKB_GSO_SIT | |
Pravin B Shelar | 7313626 | 2013-03-07 13:21:51 +0000 | [diff] [blame] | 83 | SKB_GSO_UDP_TUNNEL | |
Tom Herbert | 0f4f4ff | 2014-06-04 17:20:16 -0700 | [diff] [blame] | 84 | SKB_GSO_UDP_TUNNEL_CSUM | |
Tom Herbert | e585f23 | 2014-11-04 09:06:54 -0800 | [diff] [blame] | 85 | SKB_GSO_TUNNEL_REMCSUM | |
Alexander Duyck | 802ab55 | 2016-04-10 21:45:03 -0400 | [diff] [blame^] | 86 | SKB_GSO_PARTIAL | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 87 | 0))) |
| 88 | goto out; |
| 89 | |
Eric Dumazet | d3e5e00 | 2013-10-20 20:47:29 -0700 | [diff] [blame] | 90 | skb_reset_network_header(skb); |
| 91 | nhoff = skb_network_header(skb) - skb_mac_header(skb); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 92 | if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) |
| 93 | goto out; |
| 94 | |
Hannes Frederic Sowa | 91a48a2 | 2014-02-24 00:48:05 +0100 | [diff] [blame] | 95 | encap = SKB_GSO_CB(skb)->encap_level > 0; |
| 96 | if (encap) |
Florian Westphal | 1e16aa3 | 2014-10-20 13:49:16 +0200 | [diff] [blame] | 97 | features &= skb->dev->hw_enc_features; |
Eric Dumazet | d3e5e00 | 2013-10-20 20:47:29 -0700 | [diff] [blame] | 98 | SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h); |
| 99 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 100 | ipv6h = ipv6_hdr(skb); |
| 101 | __skb_pull(skb, sizeof(*ipv6h)); |
| 102 | segs = ERR_PTR(-EPROTONOSUPPORT); |
| 103 | |
| 104 | proto = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr); |
Eric Dumazet | b917eb1 | 2013-10-18 14:43:55 -0700 | [diff] [blame] | 105 | |
Hannes Frederic Sowa | 91a48a2 | 2014-02-24 00:48:05 +0100 | [diff] [blame] | 106 | if (skb->encapsulation && |
| 107 | skb_shinfo(skb)->gso_type & (SKB_GSO_SIT|SKB_GSO_IPIP)) |
| 108 | udpfrag = proto == IPPROTO_UDP && encap; |
| 109 | else |
| 110 | udpfrag = proto == IPPROTO_UDP && !skb->encapsulation; |
| 111 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 112 | ops = rcu_dereference(inet6_offloads[proto]); |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 113 | if (likely(ops && ops->callbacks.gso_segment)) { |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 114 | skb_reset_transport_header(skb); |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 115 | segs = ops->callbacks.gso_segment(skb, features); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 116 | } |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 117 | |
| 118 | if (IS_ERR(segs)) |
| 119 | goto out; |
| 120 | |
| 121 | for (skb = segs; skb; skb = skb->next) { |
Eric Dumazet | d3e5e00 | 2013-10-20 20:47:29 -0700 | [diff] [blame] | 122 | ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff); |
Alexander Duyck | 802ab55 | 2016-04-10 21:45:03 -0400 | [diff] [blame^] | 123 | if (skb_is_gso(skb)) |
| 124 | payload_len = skb_shinfo(skb)->gso_size + |
| 125 | SKB_GSO_CB(skb)->data_offset + |
| 126 | skb->head - (unsigned char *)(ipv6h + 1); |
| 127 | else |
| 128 | payload_len = skb->len - nhoff - sizeof(*ipv6h); |
| 129 | ipv6h->payload_len = htons(payload_len); |
Eric Dumazet | d3e5e00 | 2013-10-20 20:47:29 -0700 | [diff] [blame] | 130 | skb->network_header = (u8 *)ipv6h - skb->head; |
| 131 | |
Hannes Frederic Sowa | 91a48a2 | 2014-02-24 00:48:05 +0100 | [diff] [blame] | 132 | if (udpfrag) { |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 133 | unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr); |
Eric Dumazet | d3e5e00 | 2013-10-20 20:47:29 -0700 | [diff] [blame] | 134 | fptr = (struct frag_hdr *)((u8 *)ipv6h + unfrag_ip6hlen); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 135 | fptr->frag_off = htons(offset); |
Ian Morris | 53b24b8 | 2015-03-29 14:00:05 +0100 | [diff] [blame] | 136 | if (skb->next) |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 137 | fptr->frag_off |= htons(IP6_MF); |
| 138 | offset += (ntohs(ipv6h->payload_len) - |
| 139 | sizeof(struct frag_hdr)); |
| 140 | } |
Hannes Frederic Sowa | 91a48a2 | 2014-02-24 00:48:05 +0100 | [diff] [blame] | 141 | if (encap) |
| 142 | skb_reset_inner_headers(skb); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | out: |
| 146 | return segs; |
| 147 | } |
| 148 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 149 | /* Return the total length of all the extension hdrs, following the same |
| 150 | * logic in ipv6_gso_pull_exthdrs() when parsing ext-hdrs. |
| 151 | */ |
| 152 | static int ipv6_exthdrs_len(struct ipv6hdr *iph, |
| 153 | const struct net_offload **opps) |
| 154 | { |
Jerry Chu | 810c23a | 2013-12-15 18:48:07 -0800 | [diff] [blame] | 155 | struct ipv6_opt_hdr *opth = (void *)iph; |
| 156 | int len = 0, proto, optlen = sizeof(*iph); |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 157 | |
| 158 | proto = iph->nexthdr; |
| 159 | for (;;) { |
| 160 | if (proto != NEXTHDR_HOP) { |
| 161 | *opps = rcu_dereference(inet6_offloads[proto]); |
| 162 | if (unlikely(!(*opps))) |
| 163 | break; |
| 164 | if (!((*opps)->flags & INET6_PROTO_GSO_EXTHDR)) |
| 165 | break; |
| 166 | } |
Jerry Chu | 810c23a | 2013-12-15 18:48:07 -0800 | [diff] [blame] | 167 | opth = (void *)opth + optlen; |
| 168 | optlen = ipv6_optlen(opth); |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 169 | len += optlen; |
| 170 | proto = opth->nexthdr; |
| 171 | } |
| 172 | return len; |
| 173 | } |
| 174 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 175 | static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, |
| 176 | struct sk_buff *skb) |
| 177 | { |
| 178 | const struct net_offload *ops; |
| 179 | struct sk_buff **pp = NULL; |
| 180 | struct sk_buff *p; |
| 181 | struct ipv6hdr *iph; |
| 182 | unsigned int nlen; |
| 183 | unsigned int hlen; |
| 184 | unsigned int off; |
Jerry Chu | bf5a755 | 2014-01-07 10:23:19 -0800 | [diff] [blame] | 185 | u16 flush = 1; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 186 | int proto; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 187 | |
| 188 | off = skb_gro_offset(skb); |
| 189 | hlen = off + sizeof(*iph); |
| 190 | iph = skb_gro_header_fast(skb, off); |
| 191 | if (skb_gro_header_hard(skb, hlen)) { |
| 192 | iph = skb_gro_header_slow(skb, hlen, off); |
| 193 | if (unlikely(!iph)) |
| 194 | goto out; |
| 195 | } |
| 196 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 197 | skb_set_network_header(skb, off); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 198 | skb_gro_pull(skb, sizeof(*iph)); |
| 199 | skb_set_transport_header(skb, skb_gro_offset(skb)); |
| 200 | |
| 201 | flush += ntohs(iph->payload_len) != skb_gro_len(skb); |
| 202 | |
| 203 | rcu_read_lock(); |
| 204 | proto = iph->nexthdr; |
| 205 | ops = rcu_dereference(inet6_offloads[proto]); |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 206 | if (!ops || !ops->callbacks.gro_receive) { |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 207 | __pskb_pull(skb, skb_gro_offset(skb)); |
| 208 | proto = ipv6_gso_pull_exthdrs(skb, proto); |
| 209 | skb_gro_pull(skb, -skb_transport_offset(skb)); |
| 210 | skb_reset_transport_header(skb); |
| 211 | __skb_push(skb, skb_gro_offset(skb)); |
| 212 | |
| 213 | ops = rcu_dereference(inet6_offloads[proto]); |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 214 | if (!ops || !ops->callbacks.gro_receive) |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 215 | goto out_unlock; |
| 216 | |
| 217 | iph = ipv6_hdr(skb); |
| 218 | } |
| 219 | |
| 220 | NAPI_GRO_CB(skb)->proto = proto; |
| 221 | |
| 222 | flush--; |
| 223 | nlen = skb_network_header_len(skb); |
| 224 | |
| 225 | for (p = *head; p; p = p->next) { |
| 226 | const struct ipv6hdr *iph2; |
| 227 | __be32 first_word; /* <Version:4><Traffic_Class:8><Flow_Label:20> */ |
| 228 | |
| 229 | if (!NAPI_GRO_CB(p)->same_flow) |
| 230 | continue; |
| 231 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 232 | iph2 = (struct ipv6hdr *)(p->data + off); |
Ian Morris | 67ba415 | 2014-08-24 21:53:10 +0100 | [diff] [blame] | 233 | first_word = *(__be32 *)iph ^ *(__be32 *)iph2; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 234 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 235 | /* All fields must match except length and Traffic Class. |
| 236 | * XXX skbs on the gro_list have all been parsed and pulled |
| 237 | * already so we don't need to compare nlen |
| 238 | * (nlen != (sizeof(*iph2) + ipv6_exthdrs_len(iph2, &ops))) |
| 239 | * memcmp() alone below is suffcient, right? |
| 240 | */ |
| 241 | if ((first_word & htonl(0xF00FFFFF)) || |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 242 | memcmp(&iph->nexthdr, &iph2->nexthdr, |
| 243 | nlen - offsetof(struct ipv6hdr, nexthdr))) { |
| 244 | NAPI_GRO_CB(p)->same_flow = 0; |
| 245 | continue; |
| 246 | } |
| 247 | /* flush if Traffic Class fields are different */ |
| 248 | NAPI_GRO_CB(p)->flush |= !!(first_word & htonl(0x0FF00000)); |
| 249 | NAPI_GRO_CB(p)->flush |= flush; |
Tom Herbert | 03d56da | 2014-09-09 11:23:14 -0700 | [diff] [blame] | 250 | |
Alexander Duyck | 1530545 | 2016-04-10 21:44:57 -0400 | [diff] [blame] | 251 | /* If the previous IP ID value was based on an atomic |
| 252 | * datagram we can overwrite the value and ignore it. |
| 253 | */ |
| 254 | if (NAPI_GRO_CB(skb)->is_atomic) |
| 255 | NAPI_GRO_CB(p)->flush_id = 0; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Alexander Duyck | 1530545 | 2016-04-10 21:44:57 -0400 | [diff] [blame] | 258 | NAPI_GRO_CB(skb)->is_atomic = true; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 259 | NAPI_GRO_CB(skb)->flush |= flush; |
| 260 | |
Eric Dumazet | 4de462a | 2014-05-19 21:56:34 -0700 | [diff] [blame] | 261 | skb_gro_postpull_rcsum(skb, iph, nlen); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 262 | |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 263 | pp = ops->callbacks.gro_receive(head, skb); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 264 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 265 | out_unlock: |
| 266 | rcu_read_unlock(); |
| 267 | |
| 268 | out: |
| 269 | NAPI_GRO_CB(skb)->flush |= flush; |
| 270 | |
| 271 | return pp; |
| 272 | } |
| 273 | |
Jesse Gross | fac8e0f | 2016-03-19 09:32:01 -0700 | [diff] [blame] | 274 | static struct sk_buff **sit_gro_receive(struct sk_buff **head, |
| 275 | struct sk_buff *skb) |
| 276 | { |
| 277 | if (NAPI_GRO_CB(skb)->encap_mark) { |
| 278 | NAPI_GRO_CB(skb)->flush = 1; |
| 279 | return NULL; |
| 280 | } |
| 281 | |
| 282 | NAPI_GRO_CB(skb)->encap_mark = 1; |
| 283 | |
| 284 | return ipv6_gro_receive(head, skb); |
| 285 | } |
| 286 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 287 | static int ipv6_gro_complete(struct sk_buff *skb, int nhoff) |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 288 | { |
| 289 | const struct net_offload *ops; |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 290 | struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 291 | int err = -ENOSYS; |
| 292 | |
Eric Dumazet | feec0cb | 2015-10-19 20:40:17 -0700 | [diff] [blame] | 293 | if (skb->encapsulation) |
| 294 | skb_set_inner_network_header(skb, nhoff); |
| 295 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 296 | iph->payload_len = htons(skb->len - nhoff - sizeof(*iph)); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 297 | |
| 298 | rcu_read_lock(); |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 299 | |
| 300 | nhoff += sizeof(*iph) + ipv6_exthdrs_len(iph, &ops); |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 301 | if (WARN_ON(!ops || !ops->callbacks.gro_complete)) |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 302 | goto out_unlock; |
| 303 | |
Jerry Chu | 299603e8 | 2013-12-11 20:53:45 -0800 | [diff] [blame] | 304 | err = ops->callbacks.gro_complete(skb, nhoff); |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 305 | |
| 306 | out_unlock: |
| 307 | rcu_read_unlock(); |
| 308 | |
| 309 | return err; |
| 310 | } |
| 311 | |
Eric Dumazet | feec0cb | 2015-10-19 20:40:17 -0700 | [diff] [blame] | 312 | static int sit_gro_complete(struct sk_buff *skb, int nhoff) |
| 313 | { |
| 314 | skb->encapsulation = 1; |
| 315 | skb_shinfo(skb)->gso_type |= SKB_GSO_SIT; |
| 316 | return ipv6_gro_complete(skb, nhoff); |
| 317 | } |
| 318 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 319 | static struct packet_offload ipv6_packet_offload __read_mostly = { |
| 320 | .type = cpu_to_be16(ETH_P_IPV6), |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 321 | .callbacks = { |
Vlad Yasevich | f191a1d | 2012-11-15 08:49:23 +0000 | [diff] [blame] | 322 | .gso_segment = ipv6_gso_segment, |
| 323 | .gro_receive = ipv6_gro_receive, |
| 324 | .gro_complete = ipv6_gro_complete, |
| 325 | }, |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
Eric Dumazet | 61c1db7 | 2013-10-20 20:47:30 -0700 | [diff] [blame] | 328 | static const struct net_offload sit_offload = { |
| 329 | .callbacks = { |
Eric Dumazet | 61c1db7 | 2013-10-20 20:47:30 -0700 | [diff] [blame] | 330 | .gso_segment = ipv6_gso_segment, |
Jesse Gross | fac8e0f | 2016-03-19 09:32:01 -0700 | [diff] [blame] | 331 | .gro_receive = sit_gro_receive, |
Eric Dumazet | feec0cb | 2015-10-19 20:40:17 -0700 | [diff] [blame] | 332 | .gro_complete = sit_gro_complete, |
Eric Dumazet | 61c1db7 | 2013-10-20 20:47:30 -0700 | [diff] [blame] | 333 | }, |
| 334 | }; |
| 335 | |
Vlad Yasevich | c6b641a | 2012-11-15 08:49:22 +0000 | [diff] [blame] | 336 | static int __init ipv6_offload_init(void) |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 337 | { |
Vlad Yasevich | c6b641a | 2012-11-15 08:49:22 +0000 | [diff] [blame] | 338 | |
| 339 | if (tcpv6_offload_init() < 0) |
| 340 | pr_crit("%s: Cannot add TCP protocol offload\n", __func__); |
Vlad Yasevich | c6b641a | 2012-11-15 08:49:22 +0000 | [diff] [blame] | 341 | if (ipv6_exthdrs_offload_init() < 0) |
| 342 | pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__); |
| 343 | |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 344 | dev_add_offload(&ipv6_packet_offload); |
Eric Dumazet | 61c1db7 | 2013-10-20 20:47:30 -0700 | [diff] [blame] | 345 | |
| 346 | inet_add_offload(&sit_offload, IPPROTO_IPV6); |
| 347 | |
Vlad Yasevich | c6b641a | 2012-11-15 08:49:22 +0000 | [diff] [blame] | 348 | return 0; |
Vlad Yasevich | d1da932 | 2012-11-15 08:49:16 +0000 | [diff] [blame] | 349 | } |
| 350 | |
Vlad Yasevich | c6b641a | 2012-11-15 08:49:22 +0000 | [diff] [blame] | 351 | fs_initcall(ipv6_offload_init); |