]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
utils: Do not reset family for default, any, all addresses
authorDavid Ahern <dsahern@gmail.com>
Fri, 13 Apr 2018 16:36:33 +0000 (09:36 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 17 Apr 2018 00:00:48 +0000 (17:00 -0700)
Thomas reported a change in behavior with respect to autodectecting
address families. Specifically, 'ip ro add default via fe80::1'
syntax was failing to treat fe80::1 as an IPv6 address as it did in
prior releases. The root causes appears to be a change in family when
the default keyword is parsed.

'default', 'any' and 'all' are relevant outside of AF_INET. Leave the
family arg as is for these when setting addr.

Fixes: 93fa12418dc6 ("utils: Always specify family and ->bytelen in get_prefix_1()")
Reported-by: Thomas Deutschmann <whissi@gentoo.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Serhey Popovych <serhe.popovych@gmail.com>
lib/utils.c

index 60d7eb14b4386fb624f5367a69dc18128dfbe658..8a0bff0babebc5947765a7960d9335a907af90a8 100644 (file)
@@ -568,7 +568,7 @@ static int __get_addr_1(inet_prefix *addr, const char *name, int family)
        if (strcmp(name, "default") == 0) {
                if ((family == AF_DECnet) || (family == AF_MPLS))
                        return -1;
-               addr->family = (family != AF_UNSPEC) ? family : AF_INET;
+               addr->family = family;
                addr->bytelen = af_byte_len(addr->family);
                addr->bitlen = -2;
                addr->flags |= PREFIXLEN_SPECIFIED;
@@ -579,7 +579,7 @@ static int __get_addr_1(inet_prefix *addr, const char *name, int family)
            strcmp(name, "any") == 0) {
                if ((family == AF_DECnet) || (family == AF_MPLS))
                        return -1;
-               addr->family = AF_UNSPEC;
+               addr->family = family;
                addr->bytelen = 0;
                addr->bitlen = -2;
                return 0;