nvme.h: add an enum for cns values
[linux-2.6-block.git] / net / ipv6 / tcpv6_offload.c
CommitLineData
8663e02a
VY
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 * TCPv6 GSO/GRO support
11 */
12#include <linux/skbuff.h>
13#include <net/protocol.h>
14#include <net/tcp.h>
15#include <net/ip6_checksum.h>
16#include "ip6_offload.h"
17
8663e02a
VY
18static struct sk_buff **tcp6_gro_receive(struct sk_buff **head,
19 struct sk_buff *skb)
20{
cc5c00bb 21 /* Don't bother verifying checksum if we're going to flush anyway. */
149d0774
TH
22 if (!NAPI_GRO_CB(skb)->flush &&
23 skb_gro_checksum_validate(skb, IPPROTO_TCP,
24 ip6_gro_compute_pseudo)) {
8663e02a
VY
25 NAPI_GRO_CB(skb)->flush = 1;
26 return NULL;
8663e02a
VY
27 }
28
29 return tcp_gro_receive(head, skb);
30}
31
299603e8 32static int tcp6_gro_complete(struct sk_buff *skb, int thoff)
8663e02a
VY
33{
34 const struct ipv6hdr *iph = ipv6_hdr(skb);
35 struct tcphdr *th = tcp_hdr(skb);
36
299603e8
JC
37 th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr,
38 &iph->daddr, 0);
c3caf119 39 skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6;
8663e02a
VY
40
41 return tcp_gro_complete(skb);
42}
43
74abc20c
ED
44static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
45 netdev_features_t features)
d020f8f7
TH
46{
47 struct tcphdr *th;
48
49 if (!pskb_may_pull(skb, sizeof(*th)))
50 return ERR_PTR(-EINVAL);
51
52 if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
53 const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
54 struct tcphdr *th = tcp_hdr(skb);
55
56 /* Set up pseudo header, usually expect stack to have done
57 * this.
58 */
59
60 th->check = 0;
61 skb->ip_summed = CHECKSUM_PARTIAL;
62 __tcp_v6_send_check(skb, &ipv6h->saddr, &ipv6h->daddr);
63 }
64
65 return tcp_gso_segment(skb, features);
66}
8663e02a 67static const struct net_offload tcpv6_offload = {
f191a1d1 68 .callbacks = {
d020f8f7 69 .gso_segment = tcp6_gso_segment,
f191a1d1
VY
70 .gro_receive = tcp6_gro_receive,
71 .gro_complete = tcp6_gro_complete,
72 },
8663e02a
VY
73};
74
75int __init tcpv6_offload_init(void)
76{
77 return inet6_add_offload(&tcpv6_offload, IPPROTO_TCP);
78}