ipfw does not eat its own output

Sergey Matveychuk sem at FreeBSD.org
Thu Aug 2 16:13:59 UTC 2007


Hi.

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.

Tell me if I wrong (with examples). The patch is bellow.

-- 
Dixi.
Sem.
-------------- next part --------------
--- 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))


More information about the freebsd-net mailing list