diff options
author | Joe Stringer <joe@wand.net.nz> | 2013-07-25 03:52:05 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-07-28 05:07:15 +0200 |
commit | 024ec3deac33ddbd81f3c887506f132b24ea21a7 (patch) | |
tree | 32e21519a6180435415dc89628929d0e6ed56ecf /include/net/sctp/checksum.h | |
parent | virtio-net: put virtio net header inline with data (diff) | |
download | linux-024ec3deac33ddbd81f3c887506f132b24ea21a7.tar.xz linux-024ec3deac33ddbd81f3c887506f132b24ea21a7.zip |
net/sctp: Refactor SCTP skb checksum computation
This patch consolidates the SCTP checksum calculation code from various
places to a single new function, sctp_compute_cksum(skb, offset).
Signed-off-by: Joe Stringer <joe@wand.net.nz>
Reviewed-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sctp/checksum.h')
-rw-r--r-- | include/net/sctp/checksum.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h index 78b88aa8c810..483e6303458d 100644 --- a/include/net/sctp/checksum.h +++ b/include/net/sctp/checksum.h @@ -85,4 +85,19 @@ static inline __le32 sctp_end_cksum(__u32 crc32) return cpu_to_le32(~crc32); } +/* Calculate the CRC32C checksum of an SCTP packet. */ +static inline __le32 sctp_compute_cksum(const struct sk_buff *skb, + unsigned int offset) +{ + const struct sk_buff *iter; + + __u32 crc32 = sctp_start_cksum(skb->data + offset, + skb_headlen(skb) - offset); + skb_walk_frags(skb, iter) + crc32 = sctp_update_cksum((__u8 *) iter->data, + skb_headlen(iter), crc32); + + return sctp_end_cksum(crc32); +} + #endif /* __sctp_checksum_h__ */ |