aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorVlad Yasevich <vladislav.yasevich@hp.com>2009-02-13 03:33:42 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-16 03:03:10 -0500
commit4458f04c02a46c679a90ef71f866a415c192deb4 (patch)
treeb08aa476ab4c525ab3cb33cea6114cb262cb2941 /include
parent06e868066e3b5828383eb40ff4d1c0029100b0b5 (diff)
sctp: Clean up sctp checksumming code
The sctp crc32c checksum is always generated in little endian. So, we clean up the code to treat it as little endian and remove all the __force casts. Suggested by Herbert Xu. Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sctp.h2
-rw-r--r--include/net/sctp/checksum.h14
2 files changed, 8 insertions, 8 deletions
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index bd50b371ffaa..c2731bfe04d8 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -60,7 +60,7 @@ typedef struct sctphdr {
60 __be16 source; 60 __be16 source;
61 __be16 dest; 61 __be16 dest;
62 __be32 vtag; 62 __be32 vtag;
63 __be32 checksum; 63 __le32 checksum;
64} __attribute__((packed)) sctp_sctphdr_t; 64} __attribute__((packed)) sctp_sctphdr_t;
65 65
66#ifdef __KERNEL__ 66#ifdef __KERNEL__
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
index 2fec3c366e81..befc8d2a1b9f 100644
--- a/include/net/sctp/checksum.h
+++ b/include/net/sctp/checksum.h
@@ -46,14 +46,14 @@
46#include <net/sctp/sctp.h> 46#include <net/sctp/sctp.h>
47#include <linux/crc32c.h> 47#include <linux/crc32c.h>
48 48
49static inline __be32 sctp_crc32c(__be32 crc, u8 *buffer, u16 length) 49static inline __u32 sctp_crc32c(__u32 crc, u8 *buffer, u16 length)
50{ 50{
51 return (__force __be32)crc32c((__force u32)crc, buffer, length); 51 return crc32c(crc, buffer, length);
52} 52}
53 53
54static inline __be32 sctp_start_cksum(__u8 *buffer, __u16 length) 54static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
55{ 55{
56 __be32 crc = ~cpu_to_be32(0); 56 __u32 crc = ~(__u32)0;
57 __u8 zero[sizeof(__u32)] = {0}; 57 __u8 zero[sizeof(__u32)] = {0};
58 58
59 /* Optimize this routine to be SCTP specific, knowing how 59 /* Optimize this routine to be SCTP specific, knowing how
@@ -72,12 +72,12 @@ static inline __be32 sctp_start_cksum(__u8 *buffer, __u16 length)
72 return crc; 72 return crc;
73} 73}
74 74
75static inline __be32 sctp_update_cksum(__u8 *buffer, __u16 length, __be32 crc32) 75static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32)
76{ 76{
77 return sctp_crc32c(crc32, buffer, length); 77 return sctp_crc32c(crc32, buffer, length);
78} 78}
79 79
80static inline __be32 sctp_end_cksum(__be32 crc32) 80static inline __le32 sctp_end_cksum(__be32 crc32)
81{ 81{
82 return (__force __be32)~cpu_to_le32((__force u32)crc32); 82 return cpu_to_le32(~crc32);
83} 83}