From nobody@FreeBSD.org  Sun Oct 26 19:15:58 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 72C371065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 26 Oct 2008 19:15:58 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 612AE8FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 26 Oct 2008 19:15:58 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9QJFv0p089265
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 26 Oct 2008 19:15:57 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9QJFvBm089264;
	Sun, 26 Oct 2008 19:15:57 GMT
	(envelope-from nobody)
Message-Id: <200810261915.m9QJFvBm089264@www.freebsd.org>
Date: Sun, 26 Oct 2008 19:15:57 GMT
From: Mihail Balikov <mgb.fbsd@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: dummynet does not shape traffic with fast io enabled
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128401
>Category:       kern
>Synopsis:       [dummynet] [patch] dummynet does not shape traffic with fast IO enabled
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    oleg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 26 19:20:01 UTC 2008
>Closed-Date:    Fri Oct 31 13:36:22 UTC 2008
>Last-Modified:  Fri Oct 31 13:36:22 UTC 2008
>Originator:     Mihail Balikov
>Release:        FreeBSD6, FreeBSD7
>Organization:
Megalan Network
>Environment:
FreeBSD freebsd7.megalan.bg 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Thu Oct 23 10:51:58 EEST 2008     root@freebsd7.megalan.bg:/usr/src/sys/i386/compile/mBSD7  i386

>Description:
On freebsd7 with hz=2000 dummynet stops shaping traffic after 25 days
uptime.  I have tracked down the problem in dummynet io fast code at
ip_dummynet.c:1353

        if (q->q_time < curr_time)
                q->numbytes = io_fast ? fs->pipe->bandwidth : 0;

This comparision is incorrect. q->q_time is u_int32_t and curr_time is
u_int64_t.  After (1<<32) / hz seconds (~24days when hz=2000) q->q_time
is always smaller than curr_time.

This is long standing bug, which also affects on RED.

>How-To-Repeat:

>Fix:
1) workaround: disable io fast
   sysctl net.inet.ip.dummynet.io_fast=0

2) change q_time type to dn_key in ip_dummynet.h. ipfw userland program
   needs to be recompiled.

3) compare q_time with (curr_time & 0xffffffff). RED code (red_drops())
   also should be revised.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Oct 27 16:29:39 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128401 
Responsible-Changed-From-To: freebsd-net->oleg 
Responsible-Changed-By: oleg 
Responsible-Changed-When: Mon Oct 27 18:56:54 UTC 2008 
Responsible-Changed-Why:  
i'll look at it. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=128401 
State-Changed-From-To: open->patched 
State-Changed-By: oleg 
State-Changed-When: Tue Oct 28 14:16:37 UTC 2008 
State-Changed-Why:  
Fix commited to HEAD. 
Workaround will be commited to stable after re@ approval. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=128401 
State-Changed-From-To: patched->closed 
State-Changed-By: oleg 
State-Changed-When: Fri Oct 31 13:35:27 UTC 2008 
State-Changed-Why:  
Workaround commited to RELENG_7 RELENG_6 & RELENG_6_4. 
Thank you for your report! 


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