[U-Boot] [PATCH]Fix checksum to handle odd-length packet
Greg Ren
gren at ubicom.com
Tue Dec 8 23:27:11 CET 2009
Ah. I just realize that the endianess can be supported as simple as:
In stead of this:
xsum += (*p & 0xff00);
Use this:
xsum += (*p & ntohs(0xff00));
Greg Ren
-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Thursday, December 03, 2009 3:31 AM
To: Greg Ren
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH]Fix checksum to handle odd-length packet
Dear "Greg Ren",
In message <CB2DD11991B27C4F99935E6229450D3204E5CB91 at STORK.scenix.com>
you wrote:
>
> I am new to u-boot and got assignment to debug some networking issue.
I
> traced the checksum failure and was able to fix it with the patch
below.
It would be important to know on which system(s) you have actually
tested your patch - and on which you experienced any issues in the
first place. Please mention CPU, board, and network driver used.
> The patch is a git commit log from my local git reposite.
>
> Thanks for your time and advice.
>
> % git show cffd5fb03e0c3f116cce9f3ff825c5445a1eca3f
Please use git-format-patch / git-send-email to submit patches, see
http://www.denx.de/wiki/U-Boot/Patches for details.
> @@ -1420,12 +1420,12 @@ NetReceive(volatile uchar * inpkt, int len)
> ip->ip_off = 0;
> NetCopyIP((void*)&ip->ip_dst,
> &ip->ip_src);
> NetCopyIP((void*)&ip->ip_src,
> &NetOurIP);
> - ip->ip_sum = ~NetCksum((uchar *)ip,
> IP_HDR_SIZE_NO_UDP >> 1);
> + ip->ip_sum = ~NetCksum((uchar *)ip,
> IP_HDR_SIZE_NO_UDP);
Your mailer has line-wrapped the patch which makes it useless.
> + if (len == 1) {
> + xsum += (*p & 0xff00);
I doubt that this code is endianess-clean.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
This restaurant was advertising breakfast any time. So I ordered
french toast in the renaissance. - Steven Wright, comedian
More information about the U-Boot
mailing list