Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] Fix TCP/UDP checksums on the Broadcom SB-1
@ 2005-09-20  3:28 Daniel Jacobowitz
  2005-09-20 10:43 ` Maciej W. Rozycki
  2005-09-20 11:01 ` Ralf Baechle
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2005-09-20  3:28 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

The type of sum in csum_tcpudp_nofold is "unsigned int", so when we assign
to it in an asm() block, and we're running on a system with 64-bit
registers, it is vitally important that we sign extend it correctly before
returning to C.  Otherwise the stray high bits will be preserved into
csum_fold, and on the SB-1 processor, 32-bit arithmetic on a non
sign-extended register will yield surprising results.

This caused incorrect checksums in some UDP packets for NFS root.  The
problem was mild when using a 10.0.1.x IP address, but severe when
using 192.168.1.x.

Signed-off-by: Daniel Jacobowitz <dan@codesourcery.com>

Index: linux/include/asm-mips/checksum.h
===================================================================
--- linux.orig/include/asm-mips/checksum.h	2005-09-19 21:00:48.000000000 -0400
+++ linux/include/asm-mips/checksum.h	2005-09-19 21:52:11.000000000 -0400
@@ -149,7 +149,7 @@ static inline unsigned int csum_tcpudp_n
 	"	daddu	%0, %4		\n"
 	"	dsll32	$1, %0, 0	\n"
 	"	daddu	%0, $1		\n"
-	"	dsrl32	%0, %0, 0	\n"
+	"	dsra32	%0, %0, 0	\n"
 #endif
 	"	.set	pop"
 	: "=r" (sum)

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-20 15:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-20  3:28 [PATCH] Fix TCP/UDP checksums on the Broadcom SB-1 Daniel Jacobowitz
2005-09-20 10:43 ` Maciej W. Rozycki
2005-09-20 11:00   ` Matej Kupljen
2005-09-20 11:06     ` Ralf Baechle
2005-09-20 14:26       ` Michael Uhler
2005-09-20 14:26         ` Michael Uhler
2005-09-20 14:59         ` Ralf Baechle
2005-09-20 11:01 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox