netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: SCTP checksum patch for 2.6.26.5
       [not found] <48D7C0A2.9090406@protei.ru>
@ 2008-09-22 20:12 ` David Miller
  2008-09-22 20:36   ` Vlad Yasevich
  2008-09-23  5:19   ` Willy Tarreau
  0 siblings, 2 replies; 4+ messages in thread
From: David Miller @ 2008-09-22 20:12 UTC (permalink / raw)
  To: nickolay; +Cc: linux-kernel, linux-sctp, netdev

From: Nickolay Vinogradov <nickolay@protei.ru>
Date: Mon, 22 Sep 2008 19:58:26 +0400

CC:'ing correct mailing lists...

> 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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: SCTP checksum patch for 2.6.26.5
  2008-09-22 20:12 ` SCTP checksum patch for 2.6.26.5 David Miller
@ 2008-09-22 20:36   ` Vlad Yasevich
  2008-09-23  5:19   ` Willy Tarreau
  1 sibling, 0 replies; 4+ messages in thread
From: Vlad Yasevich @ 2008-09-22 20:36 UTC (permalink / raw)
  To: nickolay; +Cc: David Miller, linux-kernel, linux-sctp, netdev

David Miller wrote:
> From: Nickolay Vinogradov <nickolay@protei.ru>
> Date: Mon, 22 Sep 2008 19:58:26 +0400
> 
> CC:'ing correct mailing lists...
> 
>> 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


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

>>
>>
>> -- 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 majordomo@vger.kernel.org
>> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: SCTP checksum patch for 2.6.26.5
  2008-09-22 20:12 ` SCTP checksum patch for 2.6.26.5 David Miller
  2008-09-22 20:36   ` Vlad Yasevich
@ 2008-09-23  5:19   ` Willy Tarreau
  2008-09-23  5:45     ` Harvey Harrison
  1 sibling, 1 reply; 4+ messages in thread
From: Willy Tarreau @ 2008-09-23  5:19 UTC (permalink / raw)
  To: David Miller; +Cc: nickolay, linux-kernel, linux-sctp, netdev

On Mon, Sep 22, 2008 at 01:12:45PM -0700, David Miller wrote:
> From: Nickolay Vinogradov <nickolay@protei.ru>
> Date: Mon, 22 Sep 2008 19:58:26 +0400
> 
> CC:'ing correct mailing lists...
> 
> > 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;
> >   }

Nickolay,

you should use swab32(~crc32) instead. It will make use of arch-specific
optimisations when available (eg: bswap on x86).

Willy


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

* Re: SCTP checksum patch for 2.6.26.5
  2008-09-23  5:19   ` Willy Tarreau
@ 2008-09-23  5:45     ` Harvey Harrison
  0 siblings, 0 replies; 4+ messages in thread
From: Harvey Harrison @ 2008-09-23  5:45 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: David Miller, nickolay, linux-kernel, linux-sctp, netdev

On Tue, 2008-09-23 at 07:19 +0200, Willy Tarreau wrote:
> On Mon, Sep 22, 2008 at 01:12:45PM -0700, David Miller wrote:
> > From: Nickolay Vinogradov <nickolay@protei.ru>
> > Date: Mon, 22 Sep 2008 19:58:26 +0400
> > 
> > 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 <harvey.harrison@gmail.com>
Date:   Fri Jul 18 23:07:09 2008 -0700

    sctp: remove unnecessary byteshifting, calculate directly in big-endian

In Linus' tree.

Cheers,

Harvey


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <48D7C0A2.9090406@protei.ru>
2008-09-22 20:12 ` SCTP checksum patch for 2.6.26.5 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;
as well as URLs for NNTP newsgroup(s).