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;
}
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;
}
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) {
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)