From nobody@FreeBSD.org  Fri May  3 09:58:56 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id CF7F687E
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  3 May 2013 09:58:56 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [69.147.83.34])
	by mx1.freebsd.org (Postfix) with ESMTP id C22DF141E
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  3 May 2013 09:58:56 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r439wuKF030941
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 3 May 2013 09:58:56 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r439wuTU030940;
	Fri, 3 May 2013 09:58:56 GMT
	(envelope-from nobody)
Message-Id: <201305030958.r439wuTU030940@red.freebsd.org>
Date: Fri, 3 May 2013 09:58:56 GMT
From: Jens Kassel <jens.kassel@aptilo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: IPFW options need to specifed in specific order
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         178317
>Category:       kern
>Synopsis:       [ipfw] ipfw options need to specifed in specific order
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ipfw
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 03 10:00:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Mon May  6 10:10:00 UTC 2013
>Originator:     Jens Kassel
>Release:        FreeBSD 8.4-RC2
>Organization:
Aptilo Networks
>Environment:
FreeBSD jensg8.lab.sth.aptilo.com 8.4-RC2 FreeBSD 8.4-RC2 #7: Thu May  2 12:54:17 CEST 2013     root@.aptilo.local:/usr/obj/usr/src/sys/CONFIG-8  i386
>Description:
In FreeBSD 7.2 this command was successful

ipfw pipe 3 config bw 1000000kbit/s mask src-ip 0xffffffff queue 92

but with current FreeBSD 8.4-RC2 i must run the command as

ipfw pipe 3 config bw 1000000kbit/s queue 92 mask src-ip 0xffffffff

otherwise I get the error

ipfw: unrecognised option ``92''

Accordning to man page both ways should be correct.
>How-To-Repeat:

>Fix:
Switch order of arguments.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ipfw 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat May 4 21:23:57 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: Kirill Diduk <kirill.diduk@gmail.com>
To: bug-followup@FreeBSD.org, jens.kassel@aptilo.com
Cc: luigi@FreeBSD.org
Subject: Re: misc/178317: IPFW options need to specifed in specific order
Date: Sun, 5 May 2013 14:35:44 +0300

 --047d7b6dc9a814b57404dbf6fc68
 Content-Type: text/plain; charset=ISO-8859-1
 
 Hello,
 
 The problem is related to the command line parsing implementation in
 the file "sbin/ipfw/dummynet.c" (function "ipfw_config_pipe").
 
 Consider the example:
 
 # ipfw pipe 3 config bw 1000000kbit/s mask src-ip 0xffffffff queue 92
 
 When the "mask" token is encountered, it starts to parse FLOW_MASK
 options ('src-ip", etc.), and skips the "queue" option. After that,
 "92" is parsed as a standalone option which causes an "unrecognised
 option" error.
 
 I suggest a simple solution that fixes this problem (attached as
 "patch_01.txt").
 
 --------------------------------------------------------------------------------
 --- /usr/src/sbin/ipfw/dummynet.c.orig	2013-04-21 01:39:08.000000000 +0000
 +++ /usr/src/sbin/ipfw/dummynet.c	2013-05-05 08:45:58.000000000 +0000
 @@ -929,6 +929,7 @@
  			    case TOK_QUEUE:
  				    mask->extra = ~0;
  				    *flags |= DN_HAVE_MASK;
 +				    ac++; av--; /* backtrack */
  				    goto end_mask;
 
  			    case TOK_DSTIP:
 --------------------------------------------------------------------------------
 
 
 Also, there is a more elegant solution (attached as "patch_02.txt"),
 but I'm not sure about it :
 
 --------------------------------------------------------------------------------
 --- /usr/src/sbin/ipfw/dummynet.c.orig	2013-04-21 01:39:08.000000000 +0000
 +++ /usr/src/sbin/ipfw/dummynet.c	2013-05-05 10:03:40.000000000 +0000
 @@ -926,11 +926,6 @@
  				    *flags |= DN_HAVE_MASK;
  				    goto end_mask;
 
 -			    case TOK_QUEUE:
 -				    mask->extra = ~0;
 -				    *flags |= DN_HAVE_MASK;
 -				    goto end_mask;
 -
  			    case TOK_DSTIP:
  				    mask->addr_type = 4;
  				    p32 = &mask->dst_ip;
 --------------------------------------------------------------------------------
 
 
 Luigi, could you help, please? Can we remove the whole case-branch
 "TOK_QUEUE" here?
 
 If no, we can apply the first solution ("patch_01.txt"): it restores
 the previous behavior of the "ipfw" command line parsing.
 
 
 Thanks,
 Kirill
 
 P.S. This issue is also observed on other FreeBSD releases (e.g. 9.0 and 9.1).
 
 --047d7b6dc9a814b57404dbf6fc68
 Content-Type: text/plain; charset=US-ASCII; name="patch_01.txt"
 Content-Disposition: attachment; filename="patch_01.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_hgc54wgp0
 
 LS0tIC91c3Ivc3JjL3NiaW4vaXBmdy9kdW1teW5ldC5jLm9yaWcJMjAxMy0wNC0yMSAwMTozOTow
 OC4wMDAwMDAwMDAgKzAwMDAKKysrIC91c3Ivc3JjL3NiaW4vaXBmdy9kdW1teW5ldC5jCTIwMTMt
 MDUtMDUgMDg6NDU6NTguMDAwMDAwMDAwICswMDAwCkBAIC05MjksNiArOTI5LDcgQEAKIAkJCSAg
 ICBjYXNlIFRPS19RVUVVRToKIAkJCQkgICAgbWFzay0+ZXh0cmEgPSB+MDsKIAkJCQkgICAgKmZs
 YWdzIHw9IEROX0hBVkVfTUFTSzsKKwkJCQkgICAgYWMrKzsgYXYtLTsgLyogYmFja3RyYWNrICov
 CiAJCQkJICAgIGdvdG8gZW5kX21hc2s7CiAKIAkJCSAgICBjYXNlIFRPS19EU1RJUDoK
 --047d7b6dc9a814b57404dbf6fc68
 Content-Type: text/plain; charset=US-ASCII; name="patch_02.txt"
 Content-Disposition: attachment; filename="patch_02.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_hgc54zqq1
 
 LS0tIC91c3Ivc3JjL3NiaW4vaXBmdy9kdW1teW5ldC5jLm9yaWcJMjAxMy0wNC0yMSAwMTozOTow
 OC4wMDAwMDAwMDAgKzAwMDAKKysrIC91c3Ivc3JjL3NiaW4vaXBmdy9kdW1teW5ldC5jCTIwMTMt
 MDUtMDUgMTA6MDM6NDAuMDAwMDAwMDAwICswMDAwCkBAIC05MjYsMTEgKzkyNiw2IEBACiAJCQkJ
 ICAgICpmbGFncyB8PSBETl9IQVZFX01BU0s7CiAJCQkJICAgIGdvdG8gZW5kX21hc2s7CiAKLQkJ
 CSAgICBjYXNlIFRPS19RVUVVRToKLQkJCQkgICAgbWFzay0+ZXh0cmEgPSB+MDsKLQkJCQkgICAg
 KmZsYWdzIHw9IEROX0hBVkVfTUFTSzsKLQkJCQkgICAgZ290byBlbmRfbWFzazsKLQogCQkJICAg
 IGNhc2UgVE9LX0RTVElQOgogCQkJCSAgICBtYXNrLT5hZGRyX3R5cGUgPSA0OwogCQkJCSAgICBw
 MzIgPSAmbWFzay0+ZHN0X2lwOwo=
 --047d7b6dc9a814b57404dbf6fc68--

From: Luigi Rizzo <rizzo@iet.unipi.it>
To: Kirill Diduk <kirill.diduk@gmail.com>
Cc: bug-followup@FreeBSD.org, jens.kassel@aptilo.com, luigi@FreeBSD.org
Subject: Re: misc/178317: IPFW options need to specifed in specific order
Date: Sun, 5 May 2013 15:51:10 +0200

 On Sun, May 05, 2013 at 02:35:44PM +0300, Kirill Diduk wrote:
 > Hello,
 > 
 > The problem is related to the command line parsing implementation in
 > the file "sbin/ipfw/dummynet.c" (function "ipfw_config_pipe").
 > 
 > Consider the example:
 > 
 > # ipfw pipe 3 config bw 1000000kbit/s mask src-ip 0xffffffff queue 92
 > 
 > When the "mask" token is encountered, it starts to parse FLOW_MASK
 > options ('src-ip", etc.), and skips the "queue" option. After that,
 > "92" is parsed as a standalone option which causes an "unrecognised
 > option" error.
 > 
 > I suggest a simple solution that fixes this problem (attached as
 > "patch_01.txt").
 > 
 > --------------------------------------------------------------------------------
 > --- /usr/src/sbin/ipfw/dummynet.c.orig	2013-04-21 01:39:08.000000000 +0000
 > +++ /usr/src/sbin/ipfw/dummynet.c	2013-05-05 08:45:58.000000000 +0000
 > @@ -929,6 +929,7 @@
 >  			    case TOK_QUEUE:
 >  				    mask->extra = ~0;
 >  				    *flags |= DN_HAVE_MASK;
 > +				    ac++; av--; /* backtrack */
 >  				    goto end_mask;
 > 
 >  			    case TOK_DSTIP:
 > --------------------------------------------------------------------------------
 > 
 > 
 > Also, there is a more elegant solution (attached as "patch_02.txt"),
 > but I'm not sure about it :
 > 
 > --------------------------------------------------------------------------------
 > --- /usr/src/sbin/ipfw/dummynet.c.orig	2013-04-21 01:39:08.000000000 +0000
 > +++ /usr/src/sbin/ipfw/dummynet.c	2013-05-05 10:03:40.000000000 +0000
 > @@ -926,11 +926,6 @@
 >  				    *flags |= DN_HAVE_MASK;
 >  				    goto end_mask;
 > 
 > -			    case TOK_QUEUE:
 > -				    mask->extra = ~0;
 > -				    *flags |= DN_HAVE_MASK;
 > -				    goto end_mask;
 > -
 >  			    case TOK_DSTIP:
 >  				    mask->addr_type = 4;
 >  				    p32 = &mask->dst_ip;
 > --------------------------------------------------------------------------------
 > 
 > 
 > Luigi, could you help, please? Can we remove the whole case-branch
 > "TOK_QUEUE" here?
 > 
 > If no, we can apply the first solution ("patch_01.txt"): it restores
 > the previous behavior of the "ipfw" command line parsing.
 
 i haven't touched this code in a while, so i will let it
 to your judgement. I suppose that any non-mask option
 (e.g. queue, plr, delay, ... ) should exit the flow-mask
 parsing. The second patch seems more appropriate.
 
 cheers
 luigi

From: Kirill Diduk <kirill.diduk@gmail.com>
To: bug-followup@FreeBSD.org, jens.kassel@aptilo.com
Cc:  
Subject: Re: kern/178317: [ipfw] ipfw options need to specifed in specific order
Date: Mon, 6 May 2013 13:06:11 +0300

 --001a11c2bd12aaf3a904dc09d903
 Content-Type: text/plain; charset=ISO-8859-1
 
 OK, here is the final solution (attached as "patch.txt"). I reviewed
 it once again.
 
 Now, someone who has write-access to the FreeBSD svn, may have to apply it.
 
 Thanks,
 Kirill
 
 --001a11c2bd12aaf3a904dc09d903
 Content-Type: text/plain; charset=US-ASCII; name="patch.txt"
 Content-Disposition: attachment; filename="patch.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_hgdh83rh0
 
 LS0tIC91c3Ivc3JjL3NiaW4vaXBmdy9kdW1teW5ldC5jLm9yaWcJMjAxMy0wNC0yMSAwMTozOTow
 OC4wMDAwMDAwMDAgKzAwMDAKKysrIC91c3Ivc3JjL3NiaW4vaXBmdy9kdW1teW5ldC5jCTIwMTMt
 MDUtMDUgMTA6MDM6NDAuMDAwMDAwMDAwICswMDAwCkBAIC05MjYsMTEgKzkyNiw2IEBACiAJCQkJ
 ICAgICpmbGFncyB8PSBETl9IQVZFX01BU0s7CiAJCQkJICAgIGdvdG8gZW5kX21hc2s7CiAKLQkJ
 CSAgICBjYXNlIFRPS19RVUVVRToKLQkJCQkgICAgbWFzay0+ZXh0cmEgPSB+MDsKLQkJCQkgICAg
 KmZsYWdzIHw9IEROX0hBVkVfTUFTSzsKLQkJCQkgICAgZ290byBlbmRfbWFzazsKLQogCQkJICAg
 IGNhc2UgVE9LX0RTVElQOgogCQkJCSAgICBtYXNrLT5hZGRyX3R5cGUgPSA0OwogCQkJCSAgICBw
 MzIgPSAmbWFzay0+ZHN0X2lwOwo=
 --001a11c2bd12aaf3a904dc09d903--
>Unformatted:
