Subject: port-arm/22964: in_cksum_arm.c broken on armeb
To: None <gnats-bugs@gnats.netbsd.org>
From: Shoichi Miyake <smi@sm.sony.co.jp>
List: netbsd-bugs
Date: 09/26/2003 21:35:43
>Number:         22964
>Category:       port-arm
>Synopsis:       in_cksum_arm.c broken on armeb
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 26 12:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Shoichi Miyake
>Release:        NetBSD 1.6W
>Organization:
Sony Corporation
>Environment:
System: NetBSD zao1 1.6W NetBSD 1.6W (ZAO425) #14: Fri Sep 26 21:05:58 JST 2003  smi@mandolin:/work/nb/arch/evbarm/obj/sys/arch/evbarm/compile/ZAO425 evbarm	Architecture: armeb
Machine: evbarm
>Description:
	On armeb platform, tcp/udp packet/dgram is dropped because of
	wrong check sum computation.
>How-To-Repeat:
	Invoke dns lookup, telnet, rlogin
>Fix:
	Apply following patch

Index: arch/arm/arm/in_cksum_arm.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm/Attic/in_cksum_arm.c,v
retrieving revision 1.6
diff -u -r1.6 in_cksum_arm.c
--- arch/arm/arm/in_cksum_arm.c	2003/08/07 16:26:52	1.6
+++ arch/arm/arm/in_cksum_arm.c	2003/09/26 11:55:17
@@ -169,7 +169,13 @@
 
 #define ADDCARRY	{if (sum > 0xffff) sum -= 0xffff;}
 #define ROL		{sum = sum << 8;}	/* depends on recent REDUCE */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define ADDBYTE		{ROL; sum += *w; byte_swapped ^= 1;}
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
 #define ADDBYTE		{ROL; sum += (*w << 8); byte_swapped ^= 1;}
+#else
+#error define _BYTE_ORDER !!!
+#endif
 #define ADDSHORT	{sum += *(u_short *)w;}
 #define ADVANCE(n)	{w += n; mlen -= n;}
 #define ADVANCEML(n)	{mlen -= n;}

>Release-Note:
>Audit-Trail:
>Unformatted: