Date: Sat, 12 Jul 2003 01:36:06 +0200 (CEST) From: Per Hedeland <per@hedeland.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/54401: [patch] pppstats prints 0 for absolute values in range 2^31..2^32-1 Message-ID: <200307112336.h6BNa6fG074377@pluto.hedeland.org> Resent-Message-ID: <200307112340.h6BNeFdp010184@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307112336.h6BNa6fG074377>