if (in6_addr_is_null(&p->opt.in6_addr))
return -ENOEXEC;
+ (void) in_addr_prefix_to_string(AF_INET6,
+ (union in_addr_union*) &p->opt.in6_addr,
+ p->opt.prefixlen, &addr_p);
+
LIST_FOREACH(prefix, cur, ra->prefixes) {
r = in_addr_prefix_intersect(AF_INET6,
cur->opt.prefixlen,
(union in_addr_union*) &p->opt.in6_addr,
p->opt.prefixlen);
- if (r > 0) {
- _cleanup_free_ char *addr_cur = NULL;
-
- (void) in_addr_to_string(AF_INET6,
- (union in_addr_union*) &p->opt.in6_addr,
- &addr_p);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ continue;
- if (dynamic && cur->opt.prefixlen == p->opt.prefixlen)
- goto update;
+ if (dynamic && cur->opt.prefixlen == p->opt.prefixlen)
+ goto update;
- (void) in_addr_to_string(AF_INET6,
- (union in_addr_union*) &cur->opt.in6_addr,
- &addr_cur);
- log_radv("IPv6 prefix %s/%u already configured, ignoring %s/%u",
- addr_cur, cur->opt.prefixlen,
- addr_p, p->opt.prefixlen);
+ _cleanup_free_ char *addr_cur = NULL;
+ (void) in_addr_prefix_to_string(AF_INET6,
+ (union in_addr_union*) &cur->opt.in6_addr,
+ cur->opt.prefixlen, &addr_cur);
+ log_radv("IPv6 prefix %s already configured, ignoring %s",
+ strna(addr_cur), strna(addr_p));
- return -EEXIST;
- }
+ return -EEXIST;
}
p = sd_radv_prefix_ref(p);
ra->n_prefixes++;
- (void) in_addr_to_string(AF_INET6, (union in_addr_union*) &p->opt.in6_addr, &addr_p);
-
if (!dynamic) {
- log_radv("Added prefix %s/%d", addr_p, p->opt.prefixlen);
+ log_radv("Added prefix %s", strna(addr_p));
return 0;
}
cur->valid_until = valid_until;
cur->preferred_until = preferred_until;
- log_radv("Updated prefix %s/%u preferred %s valid %s",
- addr_p, p->opt.prefixlen,
+ log_radv("Updated prefix %s preferred %s valid %s",
+ strna(addr_p),
format_timespan(time_string_preferred, FORMAT_TIMESPAN_MAX,
preferred, USEC_PER_SEC),
format_timespan(time_string_valid, FORMAT_TIMESPAN_MAX,
if (!p)
return -EINVAL;
- (void) in_addr_to_string(AF_INET6,
- (union in_addr_union*) &p->opt.in6_addr,
- &pretty);
+ (void) in_addr_prefix_to_string(AF_INET6,
+ (union in_addr_union*) &p->opt.in6_addr,
+ p->opt.prefixlen, &pretty);
LIST_FOREACH(prefix, cur, ra->route_prefixes) {
- _cleanup_free_ char *addr = NULL;
r = in_addr_prefix_intersect(AF_INET6,
(union in_addr_union*) &cur->opt.in6_addr,
if (dynamic && cur->opt.prefixlen == p->opt.prefixlen)
goto update;
- (void) in_addr_to_string(AF_INET6,
- (union in_addr_union*) &cur->opt.in6_addr,
- &addr);
- log_radv("IPv6 route prefix %s/%u already configured, ignoring %s/%u",
- strempty(addr), cur->opt.prefixlen,
- strempty(pretty), p->opt.prefixlen);
+ _cleanup_free_ char *addr = NULL;
+ (void) in_addr_prefix_to_string(AF_INET6,
+ (union in_addr_union*) &cur->opt.in6_addr,
+ cur->opt.prefixlen, &addr);
+ log_radv("IPv6 route prefix %s already configured, ignoring %s",
+ strna(addr), strna(pretty));
return -EEXIST;
}
ra->n_route_prefixes++;
if (!dynamic) {
- log_radv("Added prefix %s/%u", strempty(pretty), p->opt.prefixlen);
+ log_radv("Added prefix %s", strna(pretty));
return 0;
}
if (valid_until == USEC_INFINITY)
return -EOVERFLOW;
- log_radv("Updated route prefix %s/%u valid %s",
- strempty(pretty), p->opt.prefixlen,
+ log_radv("Updated route prefix %s valid %s",
+ strna(pretty),
format_timespan(time_string_valid, FORMAT_TIMESPAN_MAX, valid, USEC_PER_SEC));
return 0;
if (DEBUG_LOGGING) {
_cleanup_free_ char *s = NULL;
- (void) in_addr_to_string(p->family, &u, &s);
- log_debug("Found range %s/%u", strna(s), prefixlen);
+ (void) in_addr_prefix_to_string(p->family, &u, prefixlen, &s);
+ log_debug("Found range %s", strna(s));
}
*found = u;
if (!address_is_ready(a)) {
_cleanup_free_ char *str = NULL;
- (void) in_addr_to_string(a->family, &a->in_addr, &str);
- log_link_debug(link, "an address %s/%u is not ready", strnull(str), a->prefixlen);
+ (void) in_addr_prefix_to_string(a->family, &a->in_addr, a->prefixlen, &str);
+ log_link_debug(link, "an address %s is not ready", strnull(str));
return 0;
}
if (r < 0) {
_cleanup_free_ char *buf = NULL;
- (void) in_addr_to_string(tmp->family, &tmp->in_addr, &buf);
- log_link_warning_errno(link, r, "Failed to remember foreign address %s/%u, ignoring: %m",
- strnull(buf), tmp->prefixlen);
+ (void) in_addr_prefix_to_string(tmp->family, &tmp->in_addr, tmp->prefixlen, &buf);
+ log_link_warning_errno(link, r, "Failed to remember foreign address %s, ignoring: %m",
+ strnull(buf));
return 0;
}
}
assert(link);
assert(addr);
- (void) in_addr_to_string(AF_INET6, addr, &buf);
+ (void) in_addr_prefix_to_string(AF_INET6, addr, prefixlen, &buf);
if (prefixlen > 64) {
- log_link_debug(link, "PD Prefix length > 64, ignoring prefix %s/%u",
- strna(buf), prefixlen);
+ log_link_debug(link, "PD Prefix length > 64, ignoring prefix %s", strna(buf));
return 0;
}
if (prefixlen == 64) {
- log_link_debug(link, "Not adding a blocking route for DHCPv6 delegated subnet %s/64 since distributed prefix is 64",
+ log_link_debug(link, "Not adding a blocking route for DHCPv6 delegated subnet %s since distributed prefix is 64",
strna(buf));
return 1;
}
if (prefixlen < 48)
- log_link_warning(link, "PD Prefix length < 48, looks unusual %s/%u",
- strna(buf), prefixlen);
+ log_link_warning(link, "PD Prefix length < 48, looks unusual: %s", strna(buf));
r = route_new(&route);
if (r < 0)
r = route_configure(route, link, dhcp6_route_handler, &ret);
if (r < 0)
- return log_link_error_errno(link, r, "Failed to set unreachable route for DHCPv6 delegated subnet %s/%u: %m",
- strna(buf), prefixlen);
+ return log_link_error_errno(link, r, "Failed to set unreachable route for DHCPv6 delegated subnet %s: %m",
+ strna(buf));
if (r > 0)
link->dhcp6_route_configured = false;
r = set_ensure_put(&link->dhcp6_routes, &route_hash_ops, ret);
if (r < 0)
- return log_link_error_errno(link, r, "Failed to store unreachable route for DHCPv6 delegated subnet %s/%u: %m",
- strna(buf), prefixlen);
+ return log_link_error_errno(link, r, "Failed to store unreachable route for DHCPv6 delegated subnet %s: %m",
+ strna(buf));
(void) set_remove(link->dhcp6_routes_old, ret);
uint64_t n_prefixes = UINT64_C(1) << (64 - pd_prefix_len);
_cleanup_free_ char *buf = NULL;
- (void) in_addr_to_string(AF_INET6, &prefix, &buf);
- log_link_debug(dhcp6_link, "Assigning up to %" PRIu64 " prefixes from %s/%u",
- n_prefixes, strna(buf), pd_prefix_len);
+ (void) in_addr_prefix_to_string(AF_INET6, &prefix, pd_prefix_len, &buf);
+ log_link_debug(dhcp6_link, "Assigning up to %" PRIu64 " prefixes from %s",
+ n_prefixes, strna(buf));
}
dhcp6_pd_prefix_distribute(dhcp6_link,
assert(link);
assert(address);
- (void) in_addr_to_string(address->family, &address->in_addr, &buffer);
+ (void) in_addr_prefix_to_string(address->family, &address->in_addr, address->prefixlen, &buffer);
if (address->cinfo.ifa_valid != CACHE_INFO_INFINITY_LIFE_TIME)
valid_str = format_timespan(valid_buf, FORMAT_TIMESPAN_MAX,
address->cinfo.ifa_valid * USEC_PER_SEC,
break;
}
- log_link_warning(link, "DHCPv6 address %s/%u (valid %s%s, preferred %s%s) conflicts the existing address %s/%u%s.",
- strnull(buffer), address->prefixlen,
+ log_link_warning(link, "DHCPv6 address %s (valid %s%s, preferred %s%s) conflicts the existing address %s %s.",
+ strna(buffer),
valid_str ? "for " : "forever", strempty(valid_str),
preferred_str ? "for " : "forever", strempty(preferred_str),
- strnull(buffer), existing->prefixlen,
+ strna(buffer),
by_ndisc ? "assigned by NDISC. Please try to use or update IPv6Token= setting "
"to change the address generated by NDISC, or disable UseAutonomousPrefix=" : "");
goto finalize;
simple_log:
- log_link_full(link, log_level, "DHCPv6 address %s/%u (valid %s%s, preferred %s%s)",
- strnull(buffer), address->prefixlen,
+ log_link_full(link, log_level, "DHCPv6 address %s (valid %s%s, preferred %s%s)",
+ strna(buffer),
valid_str ? "for " : "forever", strempty(valid_str),
preferred_str ? "for " : "forever", strempty(preferred_str));
r = address_configure(addr, link, dhcp6_address_handler, &ret);
if (r < 0)
- return log_link_error_errno(link, r, "Failed to set DHCPv6 address %s/%u: %m",
- strnull(buffer), addr->prefixlen);
+ return log_link_error_errno(link, r, "Failed to set DHCPv6 address %s: %m", strna(buffer));
if (r > 0)
link->dhcp6_address_configured = false;
r = set_ensure_put(&link->dhcp6_addresses, &address_hash_ops, ret);
if (r < 0)
- return log_link_error_errno(link, r, "Failed to store DHCPv6 address %s/%u: %m",
- strnull(buffer), addr->prefixlen);
+ return log_link_error_errno(link, r, "Failed to store DHCPv6 address %s: %m", strna(buffer));
(void) set_remove(link->dhcp6_addresses_old, ret);
if (!address_is_ready(a)) {
_cleanup_free_ char *str = NULL;
- (void) in_addr_to_string(a->family, &a->in_addr, &str);
- return (void) log_link_debug(link, "%s(): an address %s/%d is not ready.", __func__, strnull(str), a->prefixlen);
+ (void) in_addr_prefix_to_string(a->family, &a->in_addr, a->prefixlen, &str);
+ return (void) log_link_debug(link, "%s(): an address %s is not ready.", __func__, strna(str));
}
if (!link->static_routes_configured)
if (in6_addr_is_null(&router)) {
_cleanup_free_ char *buf = NULL;
- (void) in_addr_to_string(address->family, &address->in_addr, &buf);
- log_link_debug(address->link, "%s is called for %s/%u, but it is already removed, ignoring.",
- __func__, strna(buf), address->prefixlen);
+ (void) in_addr_prefix_to_string(address->family, &address->in_addr, address->prefixlen, &buf);
+ log_link_debug(address->link, "%s is called for %s, but it is already removed, ignoring.",
+ __func__, strna(buf));
return 0;
}
/* link may be NULL. */
if (DEBUG_LOGGING) {
- _cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL,
- *prefsrc = NULL, *table = NULL, *scope = NULL, *proto = NULL;
+ _cleanup_free_ char *dst = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL,
+ *table = NULL, *scope = NULL, *proto = NULL;
- if (in_addr_is_set(route->family, &route->dst)) {
- (void) in_addr_to_string(route->family, &route->dst, &dst);
- (void) asprintf(&dst_prefixlen, "/%u", route->dst_prefixlen);
- }
+ if (in_addr_is_set(route->family, &route->dst))
+ (void) in_addr_prefix_to_string(route->family, &route->dst, route->dst_prefixlen, &dst);
if (in_addr_is_set(route->family, &route->src))
(void) in_addr_to_string(route->family, &route->src, &src);
if (in_addr_is_set(route->gw_family, &route->gw))
(void) route_protocol_full_to_string_alloc(route->protocol, &proto);
log_link_debug(link,
- "%s route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
- str, strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
+ "%s route: dst: %s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
+ str, strna(dst), strna(src), strna(gw), strna(prefsrc),
strna(scope), strna(table), strna(proto),
strna(route_type_to_string(route->type)));
}
if (DEBUG_LOGGING) {
_cleanup_free_ char *from = NULL, *to = NULL, *table = NULL;
- (void) in_addr_to_string(family, &rule->from, &from);
- (void) in_addr_to_string(family, &rule->to, &to);
+ (void) in_addr_prefix_to_string(family, &rule->from, rule->from_prefixlen, &from);
+ (void) in_addr_prefix_to_string(family, &rule->to, rule->to_prefixlen, &to);
(void) manager_get_route_table_to_string(m, rule->table, &table);
log_link_debug(link,
- "%s routing policy rule: priority: %"PRIu32", %s/%u -> %s/%u, iif: %s, oif: %s, table: %s",
- str, rule->priority, strna(from), rule->from_prefixlen, strna(to), rule->to_prefixlen,
+ "%s routing policy rule: priority: %"PRIu32", %s -> %s, iif: %s, oif: %s, table: %s",
+ str, rule->priority, strna(from), strna(to),
strna(rule->iif), strna(rule->oif), strna(table));
}
}