[PATCHv2] networking: consolidate the IP checksum code

Joakim Tjernlund joakim.tjernlund at transmode.se
Wed Sep 7 07:05:36 UTC 2011


Baruch Siach <baruch at tkos.co.il> wrote on 2011/09/07 06:29:32:
>
> Hi Joakim,
>
> On Mon, Sep 05, 2011 at 10:09:14PM +0200, Joakim Tjernlund wrote:
> > > From: Baruch Siach <baruch at tkos.co.il>
> > >
> > > Use a single IP checksum routine for ping, traceroute and udhcp.
> > >
> > > Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> > > ---
> > >
> > > Changes from v1:
> > >    Fix inet_cksum() with odd length on big endian systems
> > >    Remove declaration of removed udhcp_checksum()
> >
> > This looks like it is from quagga. I cleaned that up/optimized it
> > some years ago into this(you might want to fix the types):
>
> What is the advantage of this implementation over the one I suggested (which I
> took from the traceroute code)?

It is cleaner. Optimizes better(at least on RISC like archs).
I am not sure if this is allowed on modern gcc's:
  *(uint8_t*)&tmp = *(uint8_t*)w;

You can drop the pre increment if you like.

 Jocke



More information about the busybox mailing list