|
@@ -46,9 +46,14 @@
|
|
#include <net/sctp/sctp.h>
|
|
#include <net/sctp/sctp.h>
|
|
#include <linux/crc32c.h>
|
|
#include <linux/crc32c.h>
|
|
|
|
|
|
-static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
|
|
|
|
|
|
+static inline __be32 sctp_crc32c(__be32 crc, u8 *buffer, u16 length)
|
|
{
|
|
{
|
|
- __u32 crc = ~(__u32) 0;
|
|
|
|
|
|
+ return (__force __be32)crc32c((__force u32)crc, buffer, length);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline __be32 sctp_start_cksum(__u8 *buffer, __u16 length)
|
|
|
|
+{
|
|
|
|
+ __be32 crc = ~cpu_to_be32(0);
|
|
__u8 zero[sizeof(__u32)] = {0};
|
|
__u8 zero[sizeof(__u32)] = {0};
|
|
|
|
|
|
/* Optimize this routine to be SCTP specific, knowing how
|
|
/* Optimize this routine to be SCTP specific, knowing how
|
|
@@ -56,23 +61,23 @@ static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
|
|
*/
|
|
*/
|
|
|
|
|
|
/* Calculate CRC up to the checksum. */
|
|
/* Calculate CRC up to the checksum. */
|
|
- crc = crc32c(crc, buffer, sizeof(struct sctphdr) - sizeof(__u32));
|
|
|
|
|
|
+ crc = sctp_crc32c(crc, buffer, sizeof(struct sctphdr) - sizeof(__u32));
|
|
|
|
|
|
/* Skip checksum field of the header. */
|
|
/* Skip checksum field of the header. */
|
|
- crc = crc32c(crc, zero, sizeof(__u32));
|
|
|
|
|
|
+ crc = sctp_crc32c(crc, zero, sizeof(__u32));
|
|
|
|
|
|
/* Calculate the rest of the CRC. */
|
|
/* Calculate the rest of the CRC. */
|
|
- crc = crc32c(crc, &buffer[sizeof(struct sctphdr)],
|
|
|
|
|
|
+ crc = sctp_crc32c(crc, &buffer[sizeof(struct sctphdr)],
|
|
length - sizeof(struct sctphdr));
|
|
length - sizeof(struct sctphdr));
|
|
return crc;
|
|
return crc;
|
|
}
|
|
}
|
|
|
|
|
|
-static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32)
|
|
|
|
|
|
+static inline __be32 sctp_update_cksum(__u8 *buffer, __u16 length, __be32 crc32)
|
|
{
|
|
{
|
|
- return crc32c(crc32, buffer, length);
|
|
|
|
|
|
+ return sctp_crc32c(crc32, buffer, length);
|
|
}
|
|
}
|
|
|
|
|
|
-static inline __u32 sctp_end_cksum(__u32 crc32)
|
|
|
|
|
|
+static inline __be32 sctp_end_cksum(__be32 crc32)
|
|
{
|
|
{
|
|
- return ntohl(~crc32);
|
|
|
|
|
|
+ return ~crc32;
|
|
}
|
|
}
|