lkml.org 
[lkml]   [2009]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lib/checksum.c: Fix another endianess bug
Date
From: Matt Fleming <matthew.fleming@imgtec.com>

This fix allows the generic checksum code to work on my little endian
system. The previous fix was not enough, as "buff" is a big-endian
value. Without this patch I see malformed TCP packets.

Signed-off-by: Matt Fleming <matthew.fleming@imgtec.com>
---
lib/checksum.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/checksum.c b/lib/checksum.c
index b2e2fd4..c34f030 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -55,10 +55,10 @@ static unsigned int do_csum(const unsigned char *buff, int len)
goto out;
odd = 1 & (unsigned long) buff;
if (odd) {
-#ifdef __LITTLE_ENDIAN
+#ifdef __BIG_ENDIAN
result = *buff;
#else
- result += (*buff << 8);
+ result = (*buff << 8);
#endif
len--;
buff++;
--
1.6.3.GIT


\
 
 \ /
  Last update: 2009-09-25 16:23    [W:0.153 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site