From owner-freebsd-ipfw@FreeBSD.ORG Sun May 5 13:50:02 2013 Return-Path: Delivered-To: freebsd-ipfw@smarthost.ysv.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 1DD52AB0 for ; Sun, 5 May 2013 13:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id E9B32E94 for ; Sun, 5 May 2013 13:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r45Do1WM072084 for ; Sun, 5 May 2013 13:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r45Do1Qb072083; Sun, 5 May 2013 13:50:01 GMT (envelope-from gnats) Date: Sun, 5 May 2013 13:50:01 GMT Message-Id: <201305051350.r45Do1Qb072083@freefall.freebsd.org> To: freebsd-ipfw@FreeBSD.org Cc: From: Luigi Rizzo Subject: Re: misc/178317: IPFW options need to specifed in specific order X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Luigi Rizzo List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 May 2013 13:50:02 -0000 The following reply was made to PR kern/178317; it has been noted by GNATS. From: Luigi Rizzo To: Kirill Diduk 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