* [PATCH] lib/checksum.c: Fix another endianess bug
@ 2009-09-25 14:20 Matt Fleming
2009-09-25 17:00 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2009-09-25 14:20 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: linux-kernel, Mike Frysinger
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lib/checksum.c: Fix another endianess bug
2009-09-25 14:20 [PATCH] lib/checksum.c: Fix another endianess bug Matt Fleming
@ 2009-09-25 17:00 ` Mike Frysinger
2009-09-28 8:07 ` Matt Fleming
0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2009-09-25 17:00 UTC (permalink / raw)
To: Matt Fleming; +Cc: Arnd Bergmann, linux-kernel
On Fri, Sep 25, 2009 at 10:20, Matt Fleming wrote:
> 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.
can you try this one ?
http://lkml.org/lkml/2009/6/23/597
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lib/checksum.c: Fix another endianess bug
2009-09-25 17:00 ` Mike Frysinger
@ 2009-09-28 8:07 ` Matt Fleming
2009-09-28 20:39 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2009-09-28 8:07 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Arnd Bergmann, linux-kernel
On Fri, Sep 25, 2009 at 01:00:25PM -0400, Mike Frysinger wrote:
> On Fri, Sep 25, 2009 at 10:20, Matt Fleming wrote:
> > 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.
>
> can you try this one ?
> http://lkml.org/lkml/2009/6/23/597
> -mike
Yep, that one works fine also. Thanks, Mike. Who's going to pick this
up? I'm guessing this commit is also applicable for stable? Though, I
don't know if there are any little-endian users of this code in stable.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lib/checksum.c: Fix another endianess bug
2009-09-28 8:07 ` Matt Fleming
@ 2009-09-28 20:39 ` Mike Frysinger
2009-10-24 11:59 ` Matt Fleming
0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2009-09-28 20:39 UTC (permalink / raw)
To: Matt Fleming, Andrew Morton; +Cc: Arnd Bergmann, linux-kernel
On Mon, Sep 28, 2009 at 04:07, Matt Fleming wrote:
> On Fri, Sep 25, 2009 at 01:00:25PM -0400, Mike Frysinger wrote:
>> On Fri, Sep 25, 2009 at 10:20, Matt Fleming wrote:
>> > 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.
>>
>> can you try this one ?
>> http://lkml.org/lkml/2009/6/23/597
>
> Yep, that one works fine also. Thanks, Mike. Who's going to pick this
> up? I'm guessing this commit is also applicable for stable? Though, I
> don't know if there are any little-endian users of this code in stable.
i'm converting Blackfin to it now that the LE issues should be fixed,
but i'm going to hold off on pushing the change until it can be tested
as for picking up the fix, let's ask Andrew ...
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lib/checksum.c: Fix another endianess bug
2009-09-28 20:39 ` Mike Frysinger
@ 2009-10-24 11:59 ` Matt Fleming
2009-10-24 22:51 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2009-10-24 11:59 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Andrew Morton, Arnd Bergmann, linux-kernel
On Mon, Sep 28, 2009 at 04:39:38PM -0400, Mike Frysinger wrote:
> On Mon, Sep 28, 2009 at 04:07, Matt Fleming wrote:
> > On Fri, Sep 25, 2009 at 01:00:25PM -0400, Mike Frysinger wrote:
> >> On Fri, Sep 25, 2009 at 10:20, Matt Fleming wrote:
> >> > 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.
> >>
> >> can you try this one ?
> >> http://lkml.org/lkml/2009/6/23/597
> >
> > Yep, that one works fine also. Thanks, Mike. Who's going to pick this
> > up? I'm guessing this commit is also applicable for stable? Though, I
> > don't know if there are any little-endian users of this code in stable.
>
> i'm converting Blackfin to it now that the LE issues should be fixed,
> but i'm going to hold off on pushing the change until it can be tested
>
> as for picking up the fix, let's ask Andrew ...
> -mike
Ping?
Andrew, Arnd, could one of you pick this up?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lib/checksum.c: Fix another endianess bug
2009-10-24 11:59 ` Matt Fleming
@ 2009-10-24 22:51 ` Mike Frysinger
2009-10-25 10:03 ` [PATCH] lib/checksum.c: lib/checksum: fix one more thinko Arnd Bergmann
0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2009-10-24 22:51 UTC (permalink / raw)
To: Matt Fleming; +Cc: Andrew Morton, Arnd Bergmann, linux-kernel
On Sat, Oct 24, 2009 at 07:59, Matt Fleming wrote:
> On Mon, Sep 28, 2009 at 04:39:38PM -0400, Mike Frysinger wrote:
>> On Mon, Sep 28, 2009 at 04:07, Matt Fleming wrote:
>> > On Fri, Sep 25, 2009 at 01:00:25PM -0400, Mike Frysinger wrote:
>> >> On Fri, Sep 25, 2009 at 10:20, Matt Fleming wrote:
>> >> > 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.
>> >>
>> >> can you try this one ?
>> >> http://lkml.org/lkml/2009/6/23/597
>> >
>> > Yep, that one works fine also. Thanks, Mike. Who's going to pick this
>> > up? I'm guessing this commit is also applicable for stable? Though, I
>> > don't know if there are any little-endian users of this code in stable.
>>
>> i'm converting Blackfin to it now that the LE issues should be fixed,
>> but i'm going to hold off on pushing the change until it can be tested
>>
>> as for picking up the fix, let's ask Andrew ...
>
> Ping?
>
> Andrew, Arnd, could one of you pick this up?
we've been using the generic checksum code with this fix on Blackfin
boards for the last month and havent noticed any regressions so far
...
-mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lib/checksum.c: lib/checksum: fix one more thinko
2009-10-24 22:51 ` Mike Frysinger
@ 2009-10-25 10:03 ` Arnd Bergmann
0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2009-10-25 10:03 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Matt Fleming, Andrew Morton, linux-kernel
When do_csum gets unaligned data, we really need to treat
the first byte as an even byte, not an odd byte, because
we swap the two halves later.
Found by Mike's checksum-selftest module.
Reported-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
On Sunday 25 October 2009, Mike Frysinger wrote:
> > Andrew, Arnd, could one of you pick this up?
>
> we've been using the generic checksum code with this fix on Blackfin
> boards for the last month and havent noticed any regressions so far
Mike,
sorry for my unresponsiveness on this one. I kept procrastinating
because I knew I need some to look at the whole logic again to make sure
I really get it right this time.
Andrew,
can you pick this one up to make sure we don't lose it again?
I could also put it into the asm-generic tree, but it feels out
of place there.
Arnd <><
diff --git a/lib/checksum.c b/lib/checksum.c
index b2e2fd4..45c9c93 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -56,9 +56,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
odd = 1 & (unsigned long) buff;
if (odd) {
#ifdef __LITTLE_ENDIAN
- result = *buff;
-#else
result += (*buff << 8);
+#else
+ result = *buff;
#endif
len--;
buff++;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-10-25 10:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-25 14:20 [PATCH] lib/checksum.c: Fix another endianess bug Matt Fleming
2009-09-25 17:00 ` Mike Frysinger
2009-09-28 8:07 ` Matt Fleming
2009-09-28 20:39 ` Mike Frysinger
2009-10-24 11:59 ` Matt Fleming
2009-10-24 22:51 ` Mike Frysinger
2009-10-25 10:03 ` [PATCH] lib/checksum.c: lib/checksum: fix one more thinko Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome