/* IPv6LL address may be in the tentative state, and in that case networkd has not received it.
* So, we need to dump all IPv6 addresses. */
- if (link_ipv6ll_enabled(link))
+ if (link_may_have_ipv6ll(link))
return 0;
r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_GETADDR, link->ifindex, AF_INET6);
return link->network->link_local & ADDRESS_FAMILY_IPV6;
}
+bool link_may_have_ipv6ll(Link *link) {
+ assert(link);
+
+ /*
+ * This is equivalent to link_ipv6ll_enabled() for non-WireGuard interfaces.
+ *
+ * For WireGuard interface, the kernel does not assign any IPv6LL addresses, but we can assign
+ * it manually. It is necessary to set an IPv6LL address manually to run NDisc or RADV on
+ * WireGuard interface. Note, also Multicast=yes must be set. See #17380.
+ *
+ * TODO: May be better to introduce GenerateIPv6LinkLocalAddress= setting, and use algorithms
+ * used in networkd-address-generation.c
+ */
+
+ if (link_ipv6ll_enabled(link))
+ return true;
+
+ /* IPv6LL address can be manually assigned on WireGuard interface. */
+ if (streq_ptr(link->kind, "wireguard")) {
+ Address *a;
+
+ if (!link->network)
+ return false;
+
+ ORDERED_HASHMAP_FOREACH(a, link->network->addresses_by_section) {
+ if (a->family != AF_INET6)
+ continue;
+ if (in6_addr_is_set(&a->in_addr_peer.in6))
+ continue;
+ if (in6_addr_is_link_local(&a->in_addr.in6))
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool link_ipv6_enabled(Link *link) {
assert(link);
bool link_ipv6_enabled(Link *link);
bool link_ipv6ll_enabled(Link *link);
+bool link_may_have_ipv6ll(Link *link);
int link_ipv6ll_gained(Link *link);
bool link_ipv4ll_enabled(Link *link);
bool link_radv_enabled(Link *link) {
assert(link);
- if (!link_ipv6ll_enabled(link))
+ if (!link_may_have_ipv6ll(link))
return false;
return link->network->router_prefix_delegation;