Subject: bin/3327: ping report non-duplicated reply as DUP under some conditions
To: None <>
From: None <>
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
>Originator:     enami tsugutomo
	an indivisual
>Release:        NetBSD-current 1997 Mar 13
System: NetBSD 1.2C NetBSD 1.2C (PLANTS_DOLL) #253: Wed Mar 5 13:26:28 JST 1997 i386

	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.
	Do ping on i386-port, and wait until it sends 64 packets.  You may see
	like this:

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

	Here is a pacth to use host byte order when setting and testing

cvs server: Diffing .
Index: ping.c
RCS file: /a/cvsroot/NetBSD/src/sbin/ping/ping.c,v
retrieving revision
diff -u -r1.1.1.3 ping.c
--- ping.c	1997/03/13 00:19:48
+++ 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--;
-		} else {
-			SET(icp->icmp_seq);
-		}
+		} else
+			SET(ntohs((u_short)icp->icmp_seq));
 		if (pingflags & F_QUIET)