Skip to contentSkip to conversation

utils: Do not reset family for default, any, all addresses

PATCH In review David Ahern 3 participants 3 messages Apr 13, 2018 – Apr 17, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: Do not reset family for default, any, all addresses

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()")
Cc Serhey Popovych <[email protected]>
---
 lib/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/utils.c +2 -2
index 60d7eb14b438..8a0bff0babeb 100644
@@ -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;
Signature · 1 line
2.11.0
#1 lore raw

Hi,

I can confirm that this patch solves the issue for us and restores previous behavior.

Thank you.

Signature · 3 lines
Regards,
Thomas Deutschmann / Gentoo Linux Developer
C4DD 695F A713 8F24 2AA1 5638 5849 7EE5 1D5D 74A5
#2 lore raw
In reply to David Ahern
Quoted 6 lines · On Fri, 13 Apr 2018 09:36:33 -0700 David Ahern <[email protected]> wrote:

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.

Quoted 7 lines

'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()")
Cc Serhey Popovych <[email protected]>

Looks good, thanks for fixing.
Applied