diff options
Diffstat (limited to 'include/net/ip6_checksum.h')
-rw-r--r-- | include/net/ip6_checksum.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/net/ip6_checksum.h b/include/net/ip6_checksum.h index bc1b0fda2b04..652d3d309357 100644 --- a/include/net/ip6_checksum.h +++ b/include/net/ip6_checksum.h | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <net/ip.h> | 31 | #include <net/ip.h> |
32 | #include <asm/checksum.h> | 32 | #include <asm/checksum.h> |
33 | #include <linux/in6.h> | 33 | #include <linux/in6.h> |
34 | #include <linux/tcp.h> | ||
35 | #include <linux/ipv6.h> | ||
34 | 36 | ||
35 | #ifndef _HAVE_ARCH_IPV6_CSUM | 37 | #ifndef _HAVE_ARCH_IPV6_CSUM |
36 | 38 | ||
@@ -91,4 +93,37 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | |||
91 | } | 93 | } |
92 | 94 | ||
93 | #endif | 95 | #endif |
96 | |||
97 | static __inline__ __sum16 tcp_v6_check(int len, | ||
98 | const struct in6_addr *saddr, | ||
99 | const struct in6_addr *daddr, | ||
100 | __wsum base) | ||
101 | { | ||
102 | return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base); | ||
103 | } | ||
104 | |||
105 | static inline void __tcp_v6_send_check(struct sk_buff *skb, | ||
106 | const struct in6_addr *saddr, | ||
107 | const struct in6_addr *daddr) | ||
108 | { | ||
109 | struct tcphdr *th = tcp_hdr(skb); | ||
110 | |||
111 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | ||
112 | th->check = ~tcp_v6_check(skb->len, saddr, daddr, 0); | ||
113 | skb->csum_start = skb_transport_header(skb) - skb->head; | ||
114 | skb->csum_offset = offsetof(struct tcphdr, check); | ||
115 | } else { | ||
116 | th->check = tcp_v6_check(skb->len, saddr, daddr, | ||
117 | csum_partial(th, th->doff << 2, | ||
118 | skb->csum)); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | static inline void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb) | ||
123 | { | ||
124 | struct ipv6_pinfo *np = inet6_sk(sk); | ||
125 | |||
126 | __tcp_v6_send_check(skb, &np->saddr, &np->daddr); | ||
127 | } | ||
128 | |||
94 | #endif | 129 | #endif |