[Bug 200169] ipfw table list uses IPv6 format for zero IPv4 addresses

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed May 13 16:03:37 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200169

--- Comment #1 from zuborg at gmail.com ---
The problem is in IN6_IS_ADDR_V4COMPAT macro:
ipfw2.c:

static void
table_list(uint16_t num, int need_header)
...
                        if (IN6_IS_ADDR_V4COMPAT(addr6)) {
                                /* IPv4 address */
                                inet_ntop(AF_INET, &addr6->s6_addr32[3], tbuf,
sizeof(tbuf));
                        } else {
                                /* IPv6 address */
                                inet_ntop(AF_INET6, addr6, tbuf, sizeof(tbuf));
                        }
...

netinet6/in6.h:

/*
 * IPv4 compatible
 */
#define IN6_IS_ADDR_V4COMPAT(a)         \
        ((a)->__u6_addr.__u6_addr32[0] == 0 &&  \
         (a)->__u6_addr.__u6_addr32[1] == 0 &&  \
         (a)->__u6_addr.__u6_addr32[2] == 0 &&  \
         (a)->__u6_addr.__u6_addr32[3] != 0 &&  \
         (a)->__u6_addr.__u6_addr32[3] != ntohl(1))

this macro consider values 0.0.0.0 and 0.0.0.1 as non IPv4 compatible.

# ipfw table 1 flush
# ipfw table 1 add 0.0.0.0/32
# ipfw table 1 add 0.0.0.1/32
# ipfw table 1 add 0.0.0.2/32
# ipfw table 1 add 0.0.0.128/32
# ipfw table 1 list
::/32 0
::1/32 0
0.0.0.2/32 0
0.0.0.128/32 0
#

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list