From owner-freebsd-net@FreeBSD.ORG Sun Nov 9 06:11:35 2003 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 B49E516A4CF for ; Sun, 9 Nov 2003 06:11:35 -0800 (PST) Received: from freesbee.wheel.dk (freesbee.wheel.dk [193.162.159.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE6874400E for ; Sun, 9 Nov 2003 06:11:34 -0800 (PST) (envelope-from jesper@skriver.dk) Received: by freesbee.wheel.dk (Postfix, from userid 1001) id 166A538568; Sun, 9 Nov 2003 15:11:33 +0100 (CET) Date: Sun, 9 Nov 2003 15:11:32 +0100 From: Jesper Skriver To: Harti Brandt Message-ID: <20031109141132.GB32037@FreeBSD.org> References: <20031108100926.M78050@beagle.fokus.fraunhofer.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031108100926.M78050@beagle.fokus.fraunhofer.de> User-Agent: Mutt/1.4.1i X-PGP-Fingerprint: 6B88 9CE8 66E9 E631 C9C5 5EB4 22AB F0EC F956 1C31 X-PGP-Public-Key: http://freesbee.wheel.dk/~jesper/gpgkey.pub cc: "'freebsd-net@freebsd.org'" cc: Alex Hoff Subject: Re: 64 bit packet counters 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: Sun, 09 Nov 2003 14:11:35 -0000 On Sat, Nov 08, 2003 at 10:13:48AM +0100, Harti Brandt wrote: > On Fri, 7 Nov 2003, Alex Hoff wrote: > > AH>Hi, > AH> > AH>We are attempting to implement the IF-MIB, which requires the > AH>use of 64 bit packet counters and the differentiation between > AH>multicast and broadcast pkts. Since changing the if_data (by > AH>adding new counters and changing the existing to u_int64) is a bad > AH>idea, does anyone have any good ideas on how to do this? I was > AH>thinking of tacking on a new struct (lets call it ifx_data) on at > AH>the end of the current if_net struct with the appropriate counters > AH>(i/opacket, i/obyte, i/obcast, i/omcast). Apart from having to do > AH>a little double counting is there any obvious pitfals with this > AH>approach? Does anyone have an better ideas? Is there currently any > AH>plans to update the network stack to handle this properly? > > You may lookup the discussions in the mailing lists. As far as > I remember the problem with 64 bit counting was that this needs > locks because not on all architectures you have atomic 64bit add > operations. A simple method that does not involve kernel changes (and > that I plan to implement in my snmp daemon) is to periodically monitor > the counters (depending on the interface speed) and detect wraps in > the daemon. What is done in other places is to have normal 32 bit counters that are incremented per packet, and have a background task/thread to update the 64 bit counters from the 32 bit counters. That way, we avoid the locking issue per packet. /Jesper -- Jesper Skriver, jesper(at)skriver(dot)dk - CCIE #5456 One Unix to rule them all, One Resolver to find them, One IP to bring them all and in the zone to bind them.