From nobody@FreeBSD.org  Mon Oct 13 15:00:41 2008
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 183E31065698
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Oct 2008 15:00:41 +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 0775B8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Oct 2008 15:00:41 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9DF0ex2065610
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Oct 2008 15:00:40 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9DF0eaF065608;
	Mon, 13 Oct 2008 15:00:40 GMT
	(envelope-from nobody)
Message-Id: <200810131500.m9DF0eaF065608@www.freebsd.org>
Date: Mon, 13 Oct 2008 15:00:40 GMT
From: Sergey Matveychuk <sem@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [ipfw][patch] ipfw -n nat N config caused error
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128064
>Category:       bin
>Synopsis:       [ipfw][patch] ipfw -n nat N config caused error
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 13 15:10:04 UTC 2008
>Closed-Date:    Sun Jan 11 10:52:18 UTC 2009
>Last-Modified:  Sun Jan 11 10:52:18 UTC 2009
>Originator:     Sergey Matveychuk
>Release:        
>Organization:
>Environment:
ipfw(8) does not check for -n flag when configured nat.
>Description:
ipfw -n nat N config <anything> caused an error because of an infinity loop.

When -n flag specified ipfw should not do anything except syntax analyze.
>How-To-Repeat:
# ipfw -n nat 1 config if em0
ipfw: realloc: Cannot allocate memory


>Fix:
When it does nat config, it tries to show a result rule. 
pipe/queue config does not show resuls. I think nat config should not too. A patch in an attach.

But If a committer who'll take the PR is not agree with me, he can apply a patch bellow:

--- ipfw2.c.orig        2008-10-13 18:47:14.000000000 +0400
+++ ipfw2.c     2008-10-13 18:51:43.000000000 +0400
@@ -4067,6 +4067,9 @@
        if (i)
                err(1, "setsockopt(%s)", "IP_FW_NAT_CFG");

+       if (test_only)
+               return;
+
        /* After every modification, we show the resultant rule. */
        int _ac = 3;
        char *_av[] = {"show", "config", id};


Patch attached with submission follows:

--- ipfw2.c.orig	2008-10-13 18:47:14.000000000 +0400
+++ ipfw2.c	2008-10-13 18:53:25.000000000 +0400
@@ -3855,9 +3855,6 @@
 }
 
 static void
-show_nat(int ac, char **av);
-
-static void
 print_nat_config(char *buf) {
 	struct cfg_nat *n;
 	int i, cnt, flag, off;
@@ -4066,11 +4063,6 @@
 	i = do_cmd(IP_FW_NAT_CFG, buf, off);
 	if (i)
 		err(1, "setsockopt(%s)", "IP_FW_NAT_CFG");
-
-	/* After every modification, we show the resultant rule. */
-	int _ac = 3;
-	char *_av[] = {"show", "config", id};
-	show_nat(_ac, _av);
 }
 
 static void


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Tue Oct 14 17:53:39 UTC 2008 
State-Changed-Why:  
Fixed in a similar manner in HEAD.  Will MFC after 7.1-RELEASE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128064 
Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Sat Jan 3 23:04:35 UTC 2009 
Responsible-Changed-Why:  
guess why it's being reassigned? ;) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128064 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Sun Jan 11 10:52:03 UTC 2009 
State-Changed-Why:  
Merged to RELENG_7. 

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