From owner-freebsd-net@FreeBSD.ORG Mon Dec 6 16:13:41 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E06E016A4CE for ; Mon, 6 Dec 2004 16:13:41 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 046F443D67 for ; Mon, 6 Dec 2004 16:13:41 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])iB6GDddg014814; Mon, 6 Dec 2004 18:13:39 +0200 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) iB6GDaTR091667; Mon, 6 Dec 2004 18:13:36 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)iB6GDZLq091666; Mon, 6 Dec 2004 18:13:35 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 6 Dec 2004 18:13:35 +0200 From: Giorgos Keramidas To: Gerald Heinig Message-ID: <20041206161335.GA91583@orion.daedalusnetworks.priv> References: <41B46D6D.7080702@syskonnect.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41B46D6D.7080702@syskonnect.de> cc: freebsd-net@freebsd.org Subject: Re: ping counter overflow X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2004 16:13:42 -0000 On 2004-12-06 15:32, Gerald Heinig wrote: > Hi all, > > I've run into a possible bug in ping(8) while investigating a strange > duplicate packet effect in our driver. > The effect shows up on other drivers and I believe it's due to a counter > overflow in ping. > Basically, leave ping -f on a gigabit link for a few days (for medium to > large values of "a few", ie. at least 3 or 4). Stop the ping and get > lots of duplicate packets. > I changed the 5 counter variables (nmissedmax, npackets, nreceived, > nrepeats, ntransmitted) to short (from long) to reduce the time taken to > overflow and managed to get the effect very easily - it takes about 3 > seconds on a gigabit link. > Changing these variables to their unsigned counterparts solved the problem. > My question: shouldn't these counters be unsigned? (ie. unsigned long, > instead of long) They can probably be switched to uint64_t too. I'm not sure how much time this will buy us though on links with so very high speeds. A quick calculation with a link that can push 8 Mpps indicates it will take a few dozen thousands of years to overflow a 64-bit counter, unless my Python-foo has failed me: >>> (2**64) / (365*24*3600*8000000) 73117L