Subject: bin/3327: ping report non-duplicated reply as DUP under some conditions
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 03/13/1997 21:52:36
>Number:         3327
>Category:       bin
>Synopsis:       ping reports non-duplicated reply as DUP under some condtions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 13 05:05:00 1997
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
	an indivisual
>Release:        NetBSD-current 1997 Mar 13
>Environment:
System: NetBSD plants-doll.enami.ba2.so-net.or.jp 1.2C NetBSD 1.2C (PLANTS_DOLL) #253: Wed Mar 5 13:26:28 JST 1997 enami@plants-doll.enami.ba2.so-net.or.jp:/usr/src/sys/arch/i386/compile/PLANTS_DOLL i386


>Description:
	ping reports non-duplicated reply as DUP under some condtions.  It
	occurs only on little endian machine (such as i386-port).

	This is because when clearing rcvd_tbl index is host byte order but
	when setting and testing rcvd_tbl index is network byte order.
>How-To-Repeat:
	Do ping on i386-port, and wait until it sends 64 packets.  You may see
	like this:

plants-doll# obj/ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.452 ms
			:
64 bytes from 127.0.0.1: icmp_seq=63 ttl=255 time=0.509 ms
64 bytes from 127.0.0.1: icmp_seq=64 ttl=255 time=0.546 ms (DUP!)

>Fix:
	Here is a pacth to use host byte order when setting and testing
	rcvd_tbl:

cvs server: Diffing .
Index: ping.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sbin/ping/ping.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ping.c
--- ping.c	1997/03/13 00:19:48	1.1.1.3
+++ ping.c	1997/03/13 12:39:04
@@ -841,12 +841,11 @@
 				tmax = triptime;
 		}
 
-		if (TST(icp->icmp_seq)) {
+		if (TST(ntohs((u_short)icp->icmp_seq))) {
 			nrepeats++, nreceived--;
 			dupflag=1;
-		} else {
-			SET(icp->icmp_seq);
-		}
+		} else
+			SET(ntohs((u_short)icp->icmp_seq));
 
 		if (pingflags & F_QUIET)
 			return;
>Audit-Trail:
>Unformatted: