bin/54401: [patch] pppstats prints 0 for absolute values in range
2^31..2^32-1
Per Hedeland
per at hedeland.org
Fri Jul 11 16:40:16 PDT 2003
>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 at 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:
More information about the freebsd-bugs
mailing list