SCTP checksum patch for 2.6.26.5
Subsystems (4)
SCTP checksum calculation fix for BigEndian.ntohl() doesn't do anything on BigEndian.
Makefile +0 -0
include/net/sctp/checksum.h +15 -1
@@ -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; }
net/sctp/output.c +0 -0
Signature · 4 lines
Nickolay Vinogradov Protei Research and Development Center St.Petersburg, 194044, Russia Tel.: +7 812 449 47 27
David Miller
maintainerFrom: Nickolay Vinogradov <[email protected]>
Date: Mon, 22 Sep 2008 19:58:26 +0400
Quoted 41 lines
SCTP checksum calculation fix for BigEndian.
ntohl()doesn't do anything on BigEndian.Makefile +0
-0include/net/sctp/checksum.h +15
-1@@ -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; }net/sctp/output.c +0
-1-- Nickolay VinogradovProtei Research and Development Center
St.Petersburg, 194044, Russia
Tel.: +7 812 449 47 27
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 27 lines · David Miller
From: Nickolay Vinogradov <[email protected]>
Date: Mon, 22 Sep 2008 19:58:26 +0400CC 'ing correct mailing lists...Quoted 22 lines
SCTP checksum calculation fix for BigEndian.
ntohl()doesn't do anything on BigEndian.Makefile +0
-0include/net/sctp/checksum.h +9
-1@@ -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 ;
Quoted 8 lines
net/sctp/output.c
Quoted 8 lines
include/net/sctp/checksum.h +6
-0+ + crc32 = ((byte0 <<24 ) | + (byte1 <<16 ) | + (byte2 <<8 ) | + byte3); +return crc32; }net/sctp/output.c +0
-0
Was this tested? I remember running tests with that code between big and little endian arches and it worked. So, the old code worked correclty.
I changed in 2.6.27 series to do all the calculations in network order anyway.
-vlad
Quoted 16 lines
Quoted 11 lines
-- Nickolay Vinogradov
Protei Research and Development Center
St.Petersburg, 194044, Russia
Tel.: +7 812 449 47 27
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 26 lines · David Miller
From: Nickolay Vinogradov <[email protected]>
Date: Mon, 22 Sep 2008 19:58:26 +0400CC 'ing correct mailing lists...Quoted 21 lines
SCTP checksum calculation fix for BigEndian.
ntohl()doesn't do anything on BigEndian.Makefile +0
-0include/net/sctp/checksum.h +8
-1@@ -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 ;
Quoted 8 lines
include/net/sctp/checksum.h static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32) · line 92
Quoted 8 lines
include/net/sctp/checksum.h +7
-0+ byte3 = (result>>24 ) &0xff ; + + crc32 = ((byte0 <<24 ) | + (byte1 <<16 ) | + (byte2 <<8 ) | + byte3); +return crc32; }
Nickolay,
you should use swab32(~crc32) instead. It will make use of arch-specific optimisations when available (eg: bswap on x86).
Willy
Quoted 4 lines · Willy Tarreau
Quoted 3 lines · David Miller
From: Nickolay Vinogradov <[email protected]>
Date: Mon, 22 Sep 2008 19:58:26 +0400
Quoted 8 lines
Quoted 2 lines
CC 'ing correct mailing lists...Nickolay,
you should use swab32(~crc32) instead. It will make use of arch-specific optimisations when available (eg: bswap on x86).
Willy
Or look at:
commit 336d3262df71fcd2661180bb35d5ea41b4cbca58
Author: Harvey Harrison <[email protected]> Date: Fri Jul 18 23:07:09 2008 -0700
sctp: remove unnecessary byteshifting, calculate directly in big-endian
In Linus' tree.
Cheers,
Harvey