From owner-freebsd-bugs@FreeBSD.ORG Tue Apr 22 04:00:32 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9421737B404 for ; Tue, 22 Apr 2003 04:00:32 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D7A5243FBD for ; Tue, 22 Apr 2003 04:00:31 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3MB0VUp050513 for ; Tue, 22 Apr 2003 04:00:31 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3MB0Vsk050469; Tue, 22 Apr 2003 04:00:31 -0700 (PDT) Resent-Date: Tue, 22 Apr 2003 04:00:31 -0700 (PDT) Resent-Message-Id: <200304221100.h3MB0Vsk050469@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Kozin Maxim V." Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 78C6037B401 for ; Tue, 22 Apr 2003 03:52:49 -0700 (PDT) Received: from solo.peterlink.ru (solo.peterlink.ru [195.242.2.178]) by mx1.FreeBSD.org (Postfix) with ESMTP id CDDB943FD7 for ; Tue, 22 Apr 2003 03:52:48 -0700 (PDT) (envelope-from madmax@solo.peterlink.ru) Received: from madmax by solo.peterlink.ru with local (Exim 4.12) id 197vOJ-000B6M-00 for FreeBSD-gnats-submit@freebsd.org; Tue, 22 Apr 2003 14:52:47 +0400 Message-Id: Date: Tue, 22 Apr 2003 14:52:47 +0400 From: "Kozin Maxim V." Sender: "Kozin Maxim V.,a,b,b,d" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/51274: ipfw2 create dynamic rules with parent number 65535 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Kozin Maxim V." List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Apr 2003 11:00:33 -0000 >Number: 51274 >Category: kern >Synopsis: ipfw2 create dynamic rules with parent number 65535 >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Apr 22 04:00:30 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Kozin Maxim >Release: FreeBSD 4.7-RELEASE-p7 i386 >Organization: maxes@peterlink.ru >Environment: System: FreeBSD 4.7-RELEASE-p7 i386 >Description: IPFW2 limut src-addr rule incorrect denied some clinets. >How-To-Repeat: Use rule: ipfw add 01 allow tcp from any to me 80 setup limit src-addr 20 On production serer with large number concurent connection to httpd, run command: ipfw -d sh | grep PARENT | sort -nk6 After some time, You can see result like this: 00020 0 0 (2s) PARENT 3 tcp 1.2.3.4 0 <-> 0.0.0.0 0 00020 0 0 (0s) PARENT 4 tcp 1.2.3.5 0 <-> 0.0.0.0 0 00020 0 0 (0s) PARENT 4 tcp 1.2.3.6 0 <-> 0.0.0.0 0 00020 0 0 (0s) PARENT 5 tcp 1.2.3.7 0 <-> 0.0.0.0 0 00020 0 0 (0s) PARENT 65532 tcp 2.2.3.9 0 <-> 0.0.0.0 0 00020 0 0 (0s) PARENT 65534 tcp 2.2.3.10 0 <-> 0.0.0.0 0 Host 2.2.3.9 and 2.2.3.10 blocked by ipfw, but ipfw -d sh | grep LIMIT | grep "2.2.3." show nothing. Host 2.2.3.9 and 2.2.3.10 was blocked incorrectly. After some time (10-60 sec.) records "PARENT 65532" and "PARENT 65534" go away. On httpd with 20-30 req/sec and with simultaneously 70-120 distinct IP, number of blocked client may be varied from 1 to 10. >Fix: As workaround I use next patch: /usr/src/sys/netinet/ip_fw2.c: $FreeBSD: src/sys/netinet/ip_fw2.c,v 1.6.2.3 2002/08/21 05:34:07 luigi Exp $ --- /usr/src/sys/netinet/ip_fw2.c.old Wed Aug 21 09:34:07 2002 +++ /usr/src/sys/netinet/ip_fw2.c Wed Mar 19 16:20:54 2003 @@ -617,7 +617,7 @@ ipfw_dyn_rule *old_q = q; \ \ /* remove a refcount to the parent */ \ - if (q->dyn_type == O_LIMIT) \ + if ((q->dyn_type == O_LIMIT) && (q->parent->count !=0)) \ q->parent->count--; \ DEB(printf("-- unlink entry 0x%08x %d -> 0x%08x %d, %d left\n", \ (q->id.src_ip), (q->id.src_port), \ >Release-Note: >Audit-Trail: >Unformatted: