From owner-freebsd-bugs@FreeBSD.ORG Fri Jul 11 16:40:16 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C85837B401 for ; Fri, 11 Jul 2003 16:40:16 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 31D9B43FAF for ; Fri, 11 Jul 2003 16:40:15 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6BNeFUp010185 for ; Fri, 11 Jul 2003 16:40:15 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6BNeFdp010184; Fri, 11 Jul 2003 16:40:15 -0700 (PDT) Resent-Date: Fri, 11 Jul 2003 16:40:15 -0700 (PDT) Resent-Message-Id: <200307112340.h6BNeFdp010184@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, Per Hedeland Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0492C37B401 for ; Fri, 11 Jul 2003 16:36:12 -0700 (PDT) Received: from pluto.hedeland.org (as1-2-8.mal.s.bonet.se [194.236.4.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B25143FAF for ; Fri, 11 Jul 2003 16:36:08 -0700 (PDT) (envelope-from per@hedeland.org) Received: from pluto.hedeland.org (localhost [127.0.0.1]) by pluto.hedeland.org (8.12.9/8.12.9) with ESMTP id h6BNa6DI074378 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 12 Jul 2003 01:36:07 +0200 (CEST) Received: (from per@localhost) by pluto.hedeland.org (8.12.9/8.12.9/Submit) id h6BNa6fG074377; Sat, 12 Jul 2003 01:36:06 +0200 (CEST) Message-Id: <200307112336.h6BNa6fG074377@pluto.hedeland.org> Date: Sat, 12 Jul 2003 01:36:06 +0200 (CEST) From: Per Hedeland To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/54401: [patch] pppstats prints 0 for absolute values in range 2^31..2^32-1 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Per Hedeland List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jul 2003 23:40:16 -0000 >Number: 54401 >Category: bin >Synopsis: [patch] pppstats prints 0 for absolute values in range 2^31..2^32-1 >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jul 11 16:40:14 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Per Hedeland >Release: FreeBSD 5.0-RELEASE i386 >Organization: >Environment: System: FreeBSD pluto.hedeland.org 5.0-RELEASE FreeBSD 5.0-RELEASE #6: Sun Feb 9 19:32:16 CET 2003 per@pluto.hedeland.org:/usr/src/sys/i386/compile/PLUTO i386 >Description: pppstats prints 0 for absolute values in range 2^31..2^32-1 >How-To-Repeat: Transfer a lot of data (~2+GB) via ppp. Run pppstats and see it show 0 bytes in the IN (or OUT) column. Transfer quite a bit more data (~1GB). Run pppstats again and see it still show 0 bytes. >Fix: Apparently the code attempts to prevent the display of negative delta values when the counters roll over, but the way it is done breaks the display of absolute values. The diff below should make it handle both. --- /usr/src/usr.sbin/pppstats/pppstats.c Mon Apr 22 15:44:46 2002 +++ /tmp/pppstats.c Sat Jul 12 01:18:21 2003 @@ -233,8 +233,9 @@ #endif /* STREAMS */ #define MAX0(a) ((int)(a) > 0? (a): 0) -#define V(offset) MAX0(cur.offset - old.offset) -#define W(offset) MAX0(ccs.offset - ocs.offset) +#define DIFF(cur, old) ((old) > 0 ? MAX0((cur) - (old)) : (cur)) +#define V(offset) DIFF(cur.offset, old.offset) +#define W(offset) DIFF(ccs.offset, ocs.offset) #define RATIO(c, i, u) ((c) == 0? 1.0: (u) / ((double)(c) + (i))) #define CRATE(x) RATIO(W(x.comp_bytes), W(x.inc_bytes), W(x.unc_bytes)) >Release-Note: >Audit-Trail: >Unformatted: