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:w...@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 <cb2dd11991b27c4f99935e6229450d3204e5c...@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: w...@denx.de This restaurant was advertising breakfast any time. So I ordered french toast in the renaissance. - Steven Wright, comedian _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot