From nobody@FreeBSD.org  Fri Oct 22 00:32:48 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A874D16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Oct 2004 00:32:48 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6A44243D2F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Oct 2004 00:32:48 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i9M0WmDW096217
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Oct 2004 00:32:48 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i9M0WmRT096215;
	Fri, 22 Oct 2004 00:32:48 GMT
	(envelope-from nobody)
Message-Id: <200410220032.i9M0WmRT096215@www.freebsd.org>
Date: Fri, 22 Oct 2004 00:32:48 GMT
From: John Engelhart <johne@zang.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ipfw/dummynet pipe/queue 'queue [BYTES]KBytes (red|gred) [FLOAT]/[BYTES]/[BYTES]/[FLOAT]' parameter problem
X-Send-Pr-Version: www-2.3

>Number:         72987
>Category:       kern
>Synopsis:       [ipfw] ipfw/dummynet pipe/queue 'queue [BYTES]KBytes (red|gred) [FLOAT]/[BYTES]/[BYTES]/[FLOAT]' parameter problem
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ipfw
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 22 00:40:29 GMT 2004
>Closed-Date:    Wed Jun 22 04:55:02 UTC 2011
>Last-Modified:  Wed Jun 22 04:55:02 UTC 2011
>Originator:     John Engelhart
>Release:        5.3-BETA7
>Organization:
>Environment:
FreeBSD new.zang.com 5.3-BETA7 FreeBSD 5.3-BETA7 #0: Sun Oct 17 00:32:33 EDT 2004     johne@new.zang.com:/usr/src/sys/i386/compile/new  i386
>Description:
While testing some ipfw/dummynet configurations, I ran in to a problem with the "queue #KBytes" with either red or gred MIN and MAX specification parameter.

I'm not sure if this is a display only bug, or if the display artifact is due to a more fundamental problem.

In summary, there are four parameters passed to either red or gred, ie "red 1.0/2/3/4.0".  Of concern is parameters 2 and 3.  When the "queue" parameter is specified, it can be specified in one of two ways: in "slots" (packets), or in total number of bytes (#KBytes).  The #2 and #3 RED parameters are either the min/max specified in number of slots, or the min/max specified in number of bytes.  This only happens when the queue parameter is specified in KBytes.

If you specify more than 2^15 as a value for red/gred MIN or MAX, no error is given that a parameter maximum has been exceeded.  However, when checking the pipe configuration with an "ipfw pipe show", the value displayed is not the value specified.  Thus, specifying a red/gred MIN or MAX > 32767 results in a "ipfw pipe show" as if the parameter were a signed 16 bit value, and not the value entered.

I haven't dug in to the code, nor done any exhastive tests, but watching some of the results I got the impression that the values being used by the kernel to do at least the MAX calculations were the truncated values, and not the specified ones.
>How-To-Repeat:
# ipfw pipe 10 config bw 320Kbit/sec queue 512KBytes gred 0.1/4096/131072/0.1
# ipfw pipe 10 show
00010: 320.000 Kbit/s    0 ms  512 KB 1 queues (1 buckets) 
          GRED w_q 0.099991 min_th 4096 max_th 0 max_p 0.099991
    mask: 0x00 0x00000000/0x0000 -> 0x00000000/0x0000

Note the "max_th 0" is not 131072.  Wrapped value:

# ipfw pipe 10 config bw 320Kbit/sec queue 512Kbytes gred 0.1/4096/32768/0.1
# ipfw pipe 10 show
00010: 320.000 Kbit/s    0 ms  512 KB 1 queues (1 buckets) 
          GRED w_q 0.099991 min_th 4096 max_th -32768 max_p 0.099991
    mask: 0x00 0x00000000/0x0000 -> 0x00000000/0x0000
BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp

"max_th" now at -32768.
>Fix:
Unknown.

Not sure if this is display only, or a bigger problem.  Wanted to get it logged first, and I figure an ipfw maintainer can make a faster pass at what the real problem is than I can since it's a pretty obvious bug.      
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ipfw 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Oct 25 02:12:37 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72987 
State-Changed-From-To: open->feedback 
State-Changed-By: ae 
State-Changed-When: Wed Jun 1 12:46:50 UTC 2011 
State-Changed-Why:  
Can you still reproduce this on a supported release?  

http://www.freebsd.org/cgi/query-pr.cgi?pr=72987 
State-Changed-From-To: feedback->closed 
State-Changed-By: ae 
State-Changed-When: Wed Jun 22 04:54:45 UTC 2011 
State-Changed-Why:  
Feedback timeout. 

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