datapath: Check for backported sctp_compute_cksum().
[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_next <net/sctp/checksum.h>
5
6 #ifndef HAVE_SCTP_COMPUTE_CKSUM
7 static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
8                                         unsigned int offset)
9 {
10         const struct sk_buff *iter;
11
12         __u32 crc32 = sctp_start_cksum(skb->data + offset,
13                                        skb_headlen(skb) - offset);
14         skb_walk_frags(skb, iter)
15                 crc32 = sctp_update_cksum((__u8 *) iter->data,
16                                           skb_headlen(iter), crc32);
17
18         /* Open-code sctp_end_cksum() to avoid a sparse warning due to a bug in
19          * sparse annotations in Linux fixed in 3.10 in commit eee1d5a14 (sctp:
20          * Correct type and usage of sctp_end_cksum()). */
21         return cpu_to_le32(~crc32);
22 }
23 #endif
24
25 #endif