From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 28 09:00:24 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C4A0106567A for ; Tue, 28 Sep 2010 09:00:24 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1EC798FC08 for ; Tue, 28 Sep 2010 09:00:24 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o8S90NDT019590 for ; Tue, 28 Sep 2010 09:00:23 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o8S90Nh3019564; Tue, 28 Sep 2010 09:00:23 GMT (envelope-from gnats) Resent-Date: Tue, 28 Sep 2010 09:00:23 GMT Resent-Message-Id: <201009280900.o8S90Nh3019564@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Tianjie Mao Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 402641065673 for ; Tue, 28 Sep 2010 08:59:05 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 14A3C8FC17 for ; Tue, 28 Sep 2010 08:59:05 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8S8x4YB070610 for ; Tue, 28 Sep 2010 08:59:04 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o8S8x4L2070609; Tue, 28 Sep 2010 08:59:04 GMT (envelope-from nobody) Message-Id: <201009280859.o8S8x4L2070609@www.freebsd.org> Date: Tue, 28 Sep 2010 08:59:04 GMT From: Tianjie Mao To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/151023: [patch] ping6(8) exits before all ICMPv6 echo replies are received X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2010 09:00:24 -0000 >Number: 151023 >Category: bin >Synopsis: [patch] ping6(8) exits before all ICMPv6 echo replies are received >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 28 09:00:23 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Tianjie Mao >Release: 7.2-RELEASE >Organization: >Environment: FreeBSD venus 7.2-RELEASE FreeBSD 7.2-RELEASE #5: Sat Jun 26 11:02:12 CST 2010 root@venus:/usr/src/sys/amd64/compile/IPSEC amd64 >Description: An interval timer (itimer) allows a process to do repeated work at a given frequency. If an -i or -f option is specified, the FreeBSD ping6(8) will use this value to call setitimer(2) to register the timer, then the signal handler is called at every expiry of the timer, sending an ICMPv6 packet each time. However, the KAME version of ping6 utility immediately exits the loop after knowing that it is the last packet to send, which causes unread replies from a remote host to be ignored. This is a bug and can be fixed by setting itimer to zero as soon as the last packet is sent, then continue the loop to see if any replies are received. >How-To-Repeat: Suppose there is an average RTT seconds round-trip delay between v6host1 and v6host2. INT is the interval (seconds) between packets. CNT is the total number of packets to send. Run as root on v6host1: v6host1# ping6 -i $INT -c $CNT -q v6host2 Then the reply might look like this (0.01 interval, 245.816 ms delay, 100 packets): --- ipv6.sjtu.edu.cn ping6 statistics --- 100 packets transmitted, 76 packets received, 24.0% packet loss round-trip min/avg/max/std-dev = 244.446/245.816/247.826/0.705 ms After re-adjusting $INT and switching to another destination host with a different RTT, one would simply conclude with the following formula: estimated-packets-lost = RTT / INT >Fix: Apply the attached patch to src/sbin/ping6/ping6.c and the problem will be fixed. Tested against CVS revision 1.39 but this is supposed to work on older versions as well. Patch attached with submission follows: diff -uNr ping6.c.orig ping6.c --- ping6.c.orig 2010-06-16 23:49:17.000000000 +0800 +++ ping6.c 2010-09-28 15:41:22.000000000 +0800 @@ -1091,8 +1091,14 @@ /* signal handling */ if (seenalrm) { /* last packet sent, timeout reached? */ - if (npackets && ntransmitted >= npackets) - break; + if (npackets && ntransmitted >= npackets) { + struct timeval zerotime = {0, 0}; + itimer.it_value = zerotime; + itimer.it_interval = zerotime; + (void)setitimer(ITIMER_REAL, &itimer, NULL); + seenalrm = 0; /* clear flag */ + continue; + } retransmit(); seenalrm = 0; continue; >Release-Note: >Audit-Trail: >Unformatted: