59d209b20d41af74e78f0a0a9687834e161053b3
[cascardo/ovs.git] / datapath / linux / compat / include / net / sctp / checksum.h
1 #ifndef __SCTP_CHECKSUM_WRAPPER_H
2 #define __SCTP_CHECKSUM_WRAPPER_H 1
3
4 #include <linux/version.h>
5 #include_next <net/sctp/checksum.h>
6
7 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
8 static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
9                                         unsigned int offset)
10 {
11         const struct sk_buff *iter;
12
13         __u32 crc32 = sctp_start_cksum(skb->data + offset,
14                                        skb_headlen(skb) - offset);
15         skb_walk_frags(skb, iter)
16                 crc32 = sctp_update_cksum((__u8 *) iter->data,
17                                           skb_headlen(iter), crc32);
18
19         /* Open-code sctp_end_cksum() to avoid a sparse warning due to a bug in
20          * sparse annotations in Linux fixed in 3.10 in commit eee1d5a14 (sctp:
21          * Correct type and usage of sctp_end_cksum()). */
22         return cpu_to_le32(~crc32);
23 }
24 #endif
25
26 #endif