From nobody@FreeBSD.org  Mon Nov 29 11:58:18 2010
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 9CC491065670
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Nov 2010 11:58:18 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 8AF838FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Nov 2010 11:58:18 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id oATBwIhm091638
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Nov 2010 11:58:18 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id oATBwI3M091637;
	Mon, 29 Nov 2010 11:58:18 GMT
	(envelope-from nobody)
Message-Id: <201011291158.oATBwI3M091637@red.freebsd.org>
Date: Mon, 29 Nov 2010 11:58:18 GMT
From: Aleksey <otim@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [ipfw][patch]: Change of result of a rule containing "not" after "skipto"
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         152667
>Category:       kern
>Synopsis:       [ipfw][patch]: Change of result of a rule containing "not" after "skipto"
>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:   Mon Nov 29 12:00:37 UTC 2010
>Closed-Date:    Wed Dec 01 22:34:33 UTC 2010
>Last-Modified:  Wed Dec 01 22:34:33 UTC 2010
>Originator:     Aleksey
>Release:        8.1-RELEASE
>Organization:
MKC
>Environment:
FreeBSD nas2.test 8.1-RELEASE-p1 FreeBSD 8.1-RELEASE-p1 #1: Sat Nov 27 10:06:28 OMST 2010     root@nas2.test:/usr/obj/usr/src/sys/GW  i386
>Description:
In a rule of the following after "skipto" change the logic of the modifier "not"
>How-To-Repeat:
The elementary firewall allow only outgoing connections:

ipfw add 310 check-state
ipfw add 400 skipto 500 ip from not me to any
ipfw add 410 allow ip from any to any keep-state
ipfw add 500 deny all from any to any

Allow all incoming connections if add:

ipfw add 300 skipto 400 ip from not me to any

>Fix:


Patch attached with submission follows:

--- /usr/src/sys/netinet/ipfw/ip_fw2.c.orig	2010-06-14 09:09:06.000000000 +0700
+++ /usr/src/sys/netinet/ipfw/ip_fw2.c	2010-11-29 15:53:28.000000000 +0600
@@ -2016,7 +2016,7 @@
 			    f = chain->map[f_pos];
 			    l = f->cmd_len;
 			    cmd = f->cmd;
-			    match = 1;
+			    if (!cmd->len & F_NOT) match = 1;
 			    cmdlen = 0;
 			    skip_or = 0;
 			    break;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ipfw 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Nov 29 15:25:30 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152667 

Date: Mon, 29 Nov 2010 18:25:10 +0300
From: Alex Novikov <otim@mail.ru>
Reply-To: Alex Novikov <otim@mail.ru>
To: bug-followup@FreeBSD.org,
	otim@mail.ru
Subject: Re: kern/152667: [ipfw][patch]: Change of result of a rule containing "not" after "skipto"

 Probably it is more correct
 
 Patch attached with submission follows:
 
 --- ./ip_fw2.c.orig	2010-06-14 09:09:06.000000000 +0700
 +++ ./ip_fw2.c	2010-11-29 20:40:56.000000000 +0600
 @@ -2019,7 +2019,7 @@
  			    match = 1;
  			    cmdlen = 0;
  			    skip_or = 0;
 -			    break;
 +			    continue;
  
  			case O_REJECT:
  				/*
 
Date: Mon, 29 Nov 2010 18:57:50 +0300
From: Alex Novikov <otim@mail.ru>
Reply-To: Alex Novikov <otim@mail.ru>
To: bug-followup@FreeBSD.org,
	otim@mail.ru
Subject: Re: kern/152667: [ipfw][patch]: Change of result of a rule containing "not" after "skipto"

 Close.
 Merge kern/147798
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Dec 1 22:33:24 UTC 2010 
State-Changed-Why:  
See kern/147798, already committed. 

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