netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: David Miller <davem@davemloft.net>
Cc: nickolay@protei.ru, linux-kernel@vger.kernel.org,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: SCTP checksum patch for 2.6.26.5
Date: Tue, 23 Sep 2008 07:19:20 +0200	[thread overview]
Message-ID: <20080923051920.GD24654@1wt.eu> (raw)
In-Reply-To: <20080922.131245.193705447.davem@davemloft.net>

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


  parent reply	other threads:[~2008-09-23  5:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
2008-09-23  5:45     ` Harvey Harrison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080923051920.GD24654@1wt.eu \
    --to=w@1wt.eu \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nickolay@protei.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).