IPFW my site went offline - what is the result of '1 == 1' ?

Yesterday my site went offline. Luckily I had a backdoor, and so I found there had been a 3-minute failure on the uplink, and afterwards the dynamic IPv6 prefix was changed.
That should be handled all automatically, but it didn't. It seemed that the nptv6 module in ipfw was still translating to the old prefix.

Now back in my basecamp I did some tests, and came to this piece of code (from sys/netpfil/ipfw/nptv6/nptv6.c):

Code:
        /* If address does not match the external prefix, ignore */
        if (IN6_ARE_MASKED_ADDR_EQUAL(&cfg->external, args->addr,
            &cfg->mask) != 0)
            return (0);
        /* Otherwise clear READY flag */
        cfg->flags &= ~NPTV6_READY;

The IN6_ARE_MASKED_ADDR_EQUAL macro is probably from sys/netinet6/in6_var.h,
and given these comments it seems to me the '!= 0' should rather be something like '!= 1' (or just a negation).

But I'm very tired now after a long travel, so another pair of eyes would be welcome.
 
Agree. Seems to me it should be
C:
/* If address does not match the external prefix, ignore */
        if (!IN6_ARE_MASKED_ADDR_EQUAL(&cfg->external, args->addr,
            &cfg->mask))
to be more clear and to exactly reflect "does not match" or "does not equal".

It would be so much better if many such macro definitions were replaced with "static inline" function definitions, which were added to C in the C99 standard -- 27 years ago!
 
Back
Top