Subject: port-mips/4434: arch/mips/mips/in_cksum.c is little-endian dependent
To: None <gnats-bugs@gnats.netbsd.org>
From: None <tsubai@iri.co.jp>
List: netbsd-bugs
Date: 11/05/1997 21:34:39
>Number: 4434
>Category: port-mips
>Synopsis: arch/mips/mips/in_cksum.c is little-endian dependent
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Nov 5 04:50:03 1997
>Last-Modified:
>Originator: Tsubai Masanari
>Organization:
Internet Research Institute, Inc.
>Release: NetBSD-1.3_ALPHA
>Environment:
NetBSD/news (sony news3400)
System: NetBSD wapiko 1.3_ALPHA NetBSD 1.3_ALPHA (WAPIKO) #2: Mon Nov 3 14:21:55 JST 1997 tsubai@wapiko:/a/1101/src/sys/arch/news/compile/WAPIKO news
>Description:
arch/mips/mips/in_cksum.c is little-endian dependent. The probrem
is treatment of starting or finishing byte in little-endian manner.
>How-To-Repeat:
>Fix:
*** in_cksum.c.orig Tue Aug 12 20:28:29 1997
--- in_cksum.c Sun Nov 2 20:27:06 1997
***************
*** 46,51 ****
--- 46,52 ----
#include <sys/mbuf.h>
#include <sys/cdefs.h>
#include <netinet/in.h>
+ #include <machine/endian.h>
union memptr {
unsigned int *i;
***************
*** 91,97 ****
--- 92,102 ----
*'buf' before accumulating it.
*/
if (buf.u & 0x1) {
+ #if BYTE_ORDER == BIG_ENDIAN
+ sum += *(buf.c++);
+ #else
sum += (*(buf.c++) << 8);
+ #endif
n -= 1;
odd_aligned = !odd_aligned;
}
***************
*** 203,209 ****
--- 208,218 ----
/* handle trailing byte */
if (n > 0)
+ #if BYTE_ORDER == BIG_ENDIAN
+ sum += *buf.c << 8;
+ #else
sum += *buf.c;
+ #endif
/*
* compensate for a trailing byte in previous mbuf
>Audit-Trail:
>Unformatted: