Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Aug 2006 21:48:01 +0400
From:      Yar Tikhiy <yar@comp.chem.msu.su>
To:        David Malone <dwmalone@maths.tcd.ie>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: identity crisis of 6-STABLE in ipfw ipv6 ?
Message-ID:  <20060818174800.GA16008@comp.chem.msu.su>
In-Reply-To: <200608161057.03335.jhb@freebsd.org>
References:  <200608160813.21109.kees@jeremino.homeunix.net> <20060816085353.GA96738@walton.maths.tcd.ie> <200608161057.03335.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 16, 2006 at 10:57:02AM -0400, John Baldwin wrote:
> On Wednesday 16 August 2006 04:53, David Malone wrote:
> > On Wed, Aug 16, 2006 at 08:13:20AM +0200, Kees Plonsz wrote:
> > > I just updated to 6-STABLE but my ipfw rules stopped working.
> > > It seems that "me6" is vanished into thin air.
> > > 
> > > # ipfw add 7000 allow ip from me6 to me6
> > > ipfw: hostname ``me6'' unknown
> > 
> > I think it was broken by some missing brackets in this commit:
> > 
> > 	http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/ipfw/ipfw2.c#rev1.88
> > 
> > Can you try the patch below? If it looks good, Max or I can commit
> > the fix.
> > 
> > 	David.
> 
> Note that the strcmp() != 0 doesn't need extra ()'s as != is higher than
> && in precedence.

Ditto for "ret == NULL" on the same line.  That can be spelled safely as:

	if (ret == NULL && strcmp(av, "any") != 0)

It's the precedence of && vs. || that can be mistaken easily.  The
rule is simple: && is multiplication and || is addition, with their
relative precedence the same as that of their arith counterparts.
However, it's usually safer to use more paretheses around them
because anybody but a die-hard C freak will have trouble interpreting
long chains of logical subexpressions connected by &&'s and ||'s,
with the meaning of some of them reversed by a bang. :-)

>            Operator                             Associativity
>            --------                             -------------
>            ...
>            == !=                                left to right
>            ...
>            &&                                   left to right
>            ||                                   left to right
> 
> > Index: ipfw2.c
> > ===================================================================
> > RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/ipfw/ipfw2.c,v
> > retrieving revision 1.88
> > diff -u -r1.88 ipfw2.c
> > --- ipfw2.c	14 May 2006 03:53:04 -0000	1.88
> > +++ ipfw2.c	16 Aug 2006 08:50:04 -0000
> > @@ -3707,10 +3707,10 @@
> >  	    inet_pton(AF_INET6, host, &a))
> >  		ret = add_srcip6(cmd, av);
> >  	/* XXX: should check for IPv4, not !IPv6 */
> > -	if ((ret == NULL) && proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
> > -	    !inet_pton(AF_INET6, host, &a))
> > +	if ((ret == NULL) && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
> > +	    !inet_pton(AF_INET6, host, &a)))
> >  		ret = add_srcip(cmd, av);
> > -	if ((ret == NULL) && strcmp(av, "any") != 0)
> > +	if ((ret == NULL) && (strcmp(av, "any") != 0))
> >  		ret = cmd;
> >  
> >  	free(host);
> > @@ -3733,10 +3733,10 @@
> >  	    inet_pton(AF_INET6, host, &a))
> >  		ret = add_dstip6(cmd, av);
> >  	/* XXX: should check for IPv4, not !IPv6 */
> > -	if ((ret == NULL) && proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
> > -	    !inet_pton(AF_INET6, av, &a))
> > +	if ((ret == NULL) && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
> > +	    !inet_pton(AF_INET6, av, &a)))
> >  		ret = add_dstip(cmd, av);
> > -	if ((ret == NULL) && strcmp(av, "any") != 0)
> > +	if ((ret == NULL) && (strcmp(av, "any") != 0))
> >  		ret = cmd;
> >  
> >  	free(host);
> > _______________________________________________
> > freebsd-stable@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> > To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"
> > 
> 
> -- 
> John Baldwin
> _______________________________________________
> freebsd-stable@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"

-- 
Yar



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060818174800.GA16008>