From per@hedeland.org  Fri Jul 11 16:36:12 2003
Return-Path: <per@hedeland.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0492C37B401
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <per@hedeland.org>
Reply-To: Per Hedeland <per@hedeland.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] pppstats prints 0 for absolute values in range 2^31..2^32-1
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         54401
>Category:       bin
>Synopsis:       [patch] pppstats(8) prints 0 for absolute values in range 2^31..2^32-1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    delphij
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 11 16:40:14 PDT 2003
>Closed-Date:    Tue Feb 09 22:39:27 UTC 2010
>Last-Modified:  Tue Feb 09 22:39:27 UTC 2010
>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:
State-Changed-From-To: open->closed 
State-Changed-By: delphij 
State-Changed-When: Tue Feb 9 22:38:42 UTC 2010 
State-Changed-Why:  
pppstats(8) has gone unfortunately, so close this PR. 


Responsible-Changed-From-To: freebsd-bugs->delphij 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Tue Feb 9 22:38:42 UTC 2010 
Responsible-Changed-Why:  
Take just in case I was wrong. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=54401 
>Unformatted:
