Re: csum_ipv6_magic()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I found bugs in checksum.h. A sample fix is attached below.

I perfer to use generic csum_ipv6_magic() in net/checksum.h
than this fix. Please someone show me improvements for this asm
version of csum_ipv6_magic(). 

---
Hiroyuki Machida
Sony Corp.


ChangLog entry:

* (csum_ipv6_magic): Have same paramter types as net/checksum.h.
  Correct carry computation.  Add a final carry.


Index: checksum.h
===================================================================
RCS file: /cvs/linux/include/asm-mips/checksum.h,v
retrieving revision 1.12
diff -u -p -r1.12 checksum.h
--- checksum.h	2001/10/06 19:29:25	1.12
+++ checksum.h	2001/10/22 11:16:05
@@ -197,7 +197,7 @@ static inline unsigned short ip_compute_
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
 						     struct in6_addr *daddr,
-						     __u32 len,
+						     unsigned short len,
 						     unsigned short proto,
 						     unsigned int sum) 
 {
@@ -211,49 +211,51 @@ static __inline__ unsigned short int csu
 	"addu\t%0, %6\t\t\t# csum\n\t"
 	"sltu\t$1, %0, %6\n\t"
 	"lw\t%1, 0(%2)\t\t\t# four words source address\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 4(%2)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 8(%2)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 12(%2)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 0(%3)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 4(%3)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 8(%3)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
 
 	"lw\t%1, 12(%3)\n\t"
-	"addu\t%0, $1\n\t"
+	" addu\t%0, $1\n\t"
 	"addu\t%0, %1\n\t"
-	"sltu\t$1, %0, $1\n\t"
+	"sltu\t$1, %0, %1\n\t"
+	" addu\t%0, $1\n\t"
+
 	".set\tnoat\n\t"
 	".set\tnoreorder"
 	: "=r" (sum), "=r" (proto)
 	: "r" (saddr), "r" (daddr),
-	  "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
+	  "0" (htonl((__u32)len)), "1" (htonl(proto)), "r" (sum));
 
 	return csum_fold(sum);
 }

[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux