public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* SCTP checksum patch for 2.6.26.5
@ 2008-09-22 15:58 Nickolay Vinogradov
  2008-09-22 20:12 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Nickolay Vinogradov @ 2008-09-22 15:58 UTC (permalink / raw)
  To: linux-kernel

SCTP checksum calculation fix for BigEndian.
ntohl() doesn't do anything on BigEndian.

diff --git a/Makefile b/Makefile
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
index ba75c67..2f0ed64 100644
--- a/include/net/sctp/checksum.h
+++ b/include/net/sctp/checksum.h
@@ -74,5 +74,19 @@ static inline __u32 sctp_update_cksum(__u8 *buffer, 
__u16 length, __u32 crc32)

  static inline __u32 sctp_end_cksum(__u32 crc32)
  {
-       return ntohl(~crc32);
+       __u32 result;
+       __u8 byte0, byte1, byte2, byte3;
+
+       result = ~crc32;
+
+       byte0 = result & 0xff;
+       byte1 = (result>>8) & 0xff;
+       byte2 = (result>>16) & 0xff;
+       byte3 = (result>>24) & 0xff;
+
+       crc32 = ((byte0 << 24) |
+                (byte1 << 16) |
+                (byte2 << 8)  |
+                byte3);
+       return crc32;
  }
diff --git a/net/sctp/output.c b/net/sctp/output.c


-- 
Nickolay Vinogradov
Protei Research and Development Center
St.Petersburg, 194044, Russia
Tel.: +7 812 449 47 27

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-09-23  5:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-22 15:58 SCTP checksum patch for 2.6.26.5 Nickolay Vinogradov
2008-09-22 20:12 ` David Miller
2008-09-22 20:36   ` Vlad Yasevich
2008-09-23  5:19   ` Willy Tarreau
2008-09-23  5:45     ` Harvey Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox