From rene@tunix.nl  Mon Apr 14 08:09:38 2003
Return-Path: <rene@tunix.nl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 2CC6837B401; Mon, 14 Apr 2003 08:09:38 -0700 (PDT)
Received: from bastix.tunix.nl (bastix.tunix.nl [193.79.201.39])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 8496343F3F; Mon, 14 Apr 2003 08:09:36 -0700 (PDT)
	(envelope-from rene@tunix.nl)
Received: (from root@localhost) by bastix.tunix.nl (8.9.3c/8.6.12) id RAA31501; Mon, 14 Apr 2003 17:09:48 +0200 (CEST)
Received: by bastix.tunix.nl (TUNIX txp2/smap)
	id sma030908; Mon, 14 Apr 03 17:08:09 +0200
Received: from upsilix.tunix.nl (upsilix.tunix.nl [172.16.2.22])
	by fix.tunix.nl (8.10.2+Sun/8.10.2) with ESMTP id h3EF7u901892;
	Mon, 14 Apr 2003 17:07:56 +0200 (MEST)
Received: from upsilix.tunix.nl (localhost.tunix.nl [127.0.0.1])
	by upsilix.tunix.nl (8.12.6/8.12.6) with ESMTP id h3EF7rc5072817;
	Mon, 14 Apr 2003 17:07:53 +0200 (CEST)
	(envelope-from rene@upsilix.tunix.nl)
Received: (from rene@localhost)
	by upsilix.tunix.nl (8.12.6/8.12.6/Submit) id h3EF7rd1072816;
	Mon, 14 Apr 2003 17:07:53 +0200 (CEST)
	(envelope-from rene)
Message-Id: <200304141507.h3EF7rd1072816@upsilix.tunix.nl>
Date: Mon, 14 Apr 2003 17:07:53 +0200 (CEST)
From: Rene de Vries <rene@tunix.nl>
Reply-To: Rene de Vries <rene@tunix.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc: darrenr@freebsd.org
Subject: BUG: @0 does not insert at the beginning of the list
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50948
>Category:       kern
>Synopsis:       BUG: @0 does not insert at the beginning of the list
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    darrenr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 14 08:10:11 PDT 2003
>Closed-Date:    Mon Jul 05 16:58:51 GMT 2004
>Last-Modified:  Mon Jul 05 16:58:51 GMT 2004
>Originator:     Rene de Vries
>Release:        FreeBSD 4.7-RELEASE-p3 i386/FreeBSD 5.0-20030414 i386
>Organization:
Tunix Internet Security & Training
>Environment:
	FreeBSD 4.7-RELEASE-p3 i386/FreeBSD 5.0-20030414 i386
	IPFilter 3.4.29/3.4.31

>Description:
	In previous versions of ip_filter "@0" used to insert a line
	at the beginning of the set.
	The current version simply leaves the line as it would have
	been without "@0". The bug is triggered by the fact that
	fr_hist is used both as a counter and as a boolean.

>How-To-Repeat:
	Filter rules:
		log in on lo0 from any to 192.168.1.1
		log in on lo0 from any to 192.168.1.2
		log in on lo0 from any to 192.168.1.3
		@0 log in on lo0 from any to 192.168.2.1
		@0 log in on lo0 from any to 192.168.2.2
		@0 log in on lo0 from any to 192.168.2.3

	ipfstat -i (before fix):
		log in on lo0 from any to 192.168.1.1
		log in on lo0 from any to 192.168.1.2
		log in on lo0 from any to 192.168.1.3
		log in on lo0 from any to 192.168.2.1
		log in on lo0 from any to 192.168.2.2
		log in on lo0 from any to 192.168.2.3

	ipfstat -i should then be:
		log in on lo0 from any to 192.168.2.3
		log in on lo0 from any to 192.168.2.2
		log in on lo0 from any to 192.168.2.1
		log in on lo0 from any to 192.168.1.1
		log in on lo0 from any to 192.168.1.2
		log in on lo0 from any to 192.168.1.3

>Fix:

Diff against FreeBSD 5 (current as of 14 Apr 2003)

Index: sys/contrib/ipfilter/netinet/ip_fil.c
===================================================================
RCS file: /home/fbsd-cvsrepo/src/sys/contrib/ipfilter/netinet/ip_fil.c,v
retrieving revision 1.38
diff -u -r1.38 ip_fil.c
--- sys/contrib/ipfilter/netinet/ip_fil.c	19 Feb 2003 05:47:00 -0000	1.38
+++ sys/contrib/ipfilter/netinet/ip_fil.c	14 Apr 2003 13:39:40 -0000
@@ -1025,8 +1025,8 @@
 			while ((f = *ftail))
 				ftail = &f->fr_next;
 		else {
+			ftail = fprev;
 			if (fp->fr_hits) {
-				ftail = fprev;
 				while (--fp->fr_hits && (f = *ftail))
 					ftail = &f->fr_next;
 			}
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->darrenr 
Responsible-Changed-By: kris 
Responsible-Changed-When: Fri Oct 10 22:44:14 PDT 2003 
Responsible-Changed-Why:  
Assign to ipfilter author 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50948 
State-Changed-From-To: open->feedback 
State-Changed-By: darrenr 
State-Changed-When: Tue Apr 20 06:33:07 PDT 2004 
State-Changed-Why:  
will be fixed with next ipfilter import, if not already 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50948 
State-Changed-From-To: feedback->closed 
State-Changed-By: darrenr 
State-Changed-When: Mon Jul 5 16:58:17 GMT 2004 
State-Changed-Why:  
fixed in -current & RELENG_4 

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