
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@denx.de] Sent: Thursday, December 03, 2009 3:31 AM To: Greg Ren Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH]Fix checksum to handle odd-length packet
Dear "Greg Ren",
In message CB2DD11991B27C4F99935E6229450D3204E5CB91@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