From: Yu Watanabe Date: Sat, 4 Dec 2021 21:38:46 +0000 (+0900) Subject: network: dhcp6pd: gracefully handle delegated prefix whose prefixlen is larger than 64 X-Git-Tag: v250-rc1~40^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a536ec3872b929e0036f894052d2f0a73c590a9c;p=thirdparty%2Fsystemd.git network: dhcp6pd: gracefully handle delegated prefix whose prefixlen is larger than 64 --- diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c index 0bc922d4000..b388a9f882c 100644 --- a/src/network/networkd-dhcp-prefix-delegation.c +++ b/src/network/networkd-dhcp-prefix-delegation.c @@ -667,17 +667,17 @@ static int dhcp6_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li static int dhcp6_request_unreachable_route(Link *link, const struct in6_addr *addr, uint8_t prefixlen, usec_t lifetime_usec) { _cleanup_(route_freep) Route *route = NULL; - _cleanup_free_ char *buf = NULL; Route *existing; int r; assert(link); assert(addr); - (void) in6_addr_prefix_to_string(addr, prefixlen, &buf); + if (prefixlen >= 64) { + _cleanup_free_ char *buf = NULL; - if (prefixlen == 64) { - log_link_debug(link, "Not adding a blocking route for DHCPv6 delegated subnet %s since distributed prefix is 64", + (void) in6_addr_prefix_to_string(addr, prefixlen, &buf); + log_link_debug(link, "Not adding a blocking route for DHCPv6 delegated prefix %s since the prefix has length >= 64.", strna(buf)); return 0; } @@ -703,9 +703,13 @@ static int dhcp6_request_unreachable_route(Link *link, const struct in6_addr *ad r = link_request_route(link, TAKE_PTR(route), true, &link->dhcp6_messages, dhcp6_route_handler, NULL); - if (r < 0) + if (r < 0) { + _cleanup_free_ char *buf = NULL; + + (void) in6_addr_prefix_to_string(addr, prefixlen, &buf); return log_link_error_errno(link, r, "Failed to request unreachable route for DHCPv6 delegated subnet %s: %m", strna(buf)); + } return 0; } @@ -743,7 +747,7 @@ static int dhcp6_pd_prefix_add(Link *link, const struct in6_addr *prefix, uint8_ if (r < 0) return log_link_error_errno(link, r, "Failed to store DHCPv6 PD prefix %s: %m", strna(buf)); - return prefixlen <= 64; + return 0; } static int dhcp6_pd_assign_prefixes(Link *link, Link *uplink) { @@ -826,8 +830,6 @@ int dhcp6_pd_prefix_acquired(Link *dhcp6_link) { r = dhcp6_pd_prefix_add(dhcp6_link, &pd_prefix, pd_prefix_len); if (r < 0) return r; - if (r == 0) - continue; r = dhcp6_request_unreachable_route(dhcp6_link, &pd_prefix, pd_prefix_len, lifetime_valid_usec); if (r < 0)