2 * IPV6 GSO/GRO offload support
3 * Linux INET6 implementation
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.
10 * TCPv6 GSO/GRO support
12 #include <linux/skbuff.h>
13 #include <net/protocol.h>
15 #include <net/ip6_checksum.h>
16 #include "ip6_offload.h"
18 static int tcp_v6_gso_send_check(struct sk_buff
*skb
)
20 const struct ipv6hdr
*ipv6h
;
23 if (!pskb_may_pull(skb
, sizeof(*th
)))
26 ipv6h
= ipv6_hdr(skb
);
30 skb
->ip_summed
= CHECKSUM_PARTIAL
;
31 __tcp_v6_send_check(skb
, &ipv6h
->saddr
, &ipv6h
->daddr
);
35 static struct sk_buff
**tcp6_gro_receive(struct sk_buff
**head
,
38 const struct ipv6hdr
*iph
= skb_gro_network_header(skb
);
41 /* Don't bother verifying checksum if we're going to flush anyway. */
42 if (NAPI_GRO_CB(skb
)->flush
)
47 switch (skb
->ip_summed
) {
49 wsum
= skb_checksum(skb
, skb_gro_offset(skb
), skb_gro_len(skb
),
54 case CHECKSUM_COMPLETE
:
55 if (!tcp_v6_check(skb_gro_len(skb
), &iph
->saddr
, &iph
->daddr
,
57 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
61 NAPI_GRO_CB(skb
)->flush
= 1;
66 return tcp_gro_receive(head
, skb
);
69 static int tcp6_gro_complete(struct sk_buff
*skb
, int thoff
)
71 const struct ipv6hdr
*iph
= ipv6_hdr(skb
);
72 struct tcphdr
*th
= tcp_hdr(skb
);
74 th
->check
= ~tcp_v6_check(skb
->len
- thoff
, &iph
->saddr
,
76 skb_shinfo(skb
)->gso_type
= SKB_GSO_TCPV6
;
78 return tcp_gro_complete(skb
);
81 static const struct net_offload tcpv6_offload
= {
83 .gso_send_check
= tcp_v6_gso_send_check
,
84 .gso_segment
= tcp_gso_segment
,
85 .gro_receive
= tcp6_gro_receive
,
86 .gro_complete
= tcp6_gro_complete
,
90 int __init
tcpv6_offload_init(void)
92 return inet6_add_offload(&tcpv6_offload
, IPPROTO_TCP
);