From nobody@FreeBSD.org  Fri Aug  3 14:56:43 2007
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 F286816A417
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  3 Aug 2007 14:56:43 +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 DDE4013C45A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  3 Aug 2007 14:56:43 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l73Euh3A053946
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 3 Aug 2007 14:56:43 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l73EuhGm053945;
	Fri, 3 Aug 2007 14:56:43 GMT
	(envelope-from nobody)
Message-Id: <200708031456.l73EuhGm053945@www.freebsd.org>
Date: Fri, 3 Aug 2007 14:56:43 GMT
From: Sergey Matveychuk <sem@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ipfw list show some rules with a wrong format
X-Send-Pr-Version: www-3.0

>Number:         115172
>Category:       bin
>Synopsis:       [patch] ipfw(8) list show some rules with a wrong format
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ipfw
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 03 15:00:06 GMT 2007
>Closed-Date:    Mon Mar 15 19:02:28 UTC 2010
>Last-Modified:  Mon Mar 15 19:02:28 UTC 2010
>Originator:     Sergey Matveychuk
>Release:        
>Organization:
>Environment:
FreeBSD orange.yandex.net 6.2-STABLE FreeBSD 6.2-STABLE #3: Mon Jul 30 16:35:23 UTC 2007     root@orange.yandex.net:/usr/obj/usr/src/sys/ORANGE  i386

>Description:
I think quite many people met a situation when you want to save current rules with 'ipfw list' command and use it as ipfw input afterwards? (Yes, you should add a 'add' word before each line). But here we meet a weird problem: 'ipfw list' outputs a wrong rule format sometime and you can't use it without a modification.

The problem with 'to { ... or ... }' blocks. Let's see an example:
you add the rule:
ipfw add 100 allow tcp from { 10.10.10.1 or 10.10.10.2 } to { 10.10.10.3 or 10.10.10.4 or 10.10.10.5 }

adn it's showed as:
00100 allow tcp from { 10.10.10.1 or 10.10.10.2 } to { 10.10.10.3 or dst-ip 10.10.10.4 or dst-ip 10.10.10.5 }

dst-ip words are wrong here. if you'll try to add the rule in this format you get an error:
ipfw: missing ")"

I think it's a known and long standing problem.
(I've found it's introduced with the commit: Revision 1.11:
Mon Aug 19 04:52:15 2002 UTC (4 years, 11 months ago) by luigi )

After investigation I've found a strange assumption in show_prerequisites() function. It looks wrong. So I think we can remove it easily. It'll fix the problem. I've tried a lot of syntax variants and I can't see something wrong in output after the modification.
>How-To-Repeat:
see above
>Fix:
--- sbin/ipfw/ipfw2.c.orig	Thu Aug  2 13:44:45 2007
+++ sbin/ipfw/ipfw2.c	Thu Aug  2 15:17:44 2007
@@ -1394,9 +1394,6 @@
 {
 	if (comment_only)
 		return;
-	if ( (*flags & HAVE_IP) == HAVE_IP)
-		*flags |= HAVE_OPTIONS;
-
 	if ( !(*flags & HAVE_OPTIONS)) {
 		if ( !(*flags & HAVE_PROTO) && (want & HAVE_PROTO))
 			if ( (*flags & HAVE_PROTO4))


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ipfw 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Aug 3 22:40:33 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: Gavin Atkinson <gavin@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/115172: [patch] ipfw(8) list show some rules with a wrong
 format
Date: Fri, 1 Jan 2010 19:59:32 +0000 (GMT)

 This is still an issue with HEAD.
 
State-Changed-From-To: open->closed 
State-Changed-By: sem 
State-Changed-When: Mon Mar 15 19:02:28 UTC 2010 
State-Changed-Why:  
Fixed with r205179 

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