}
static int ipv4ll_set_address(Link *link) {
+ int r;
+
assert(link);
assert(link->network);
assert(link->ipv4ll);
if (in4_addr_is_set(&link->network->ipv4ll_start_address))
return sd_ipv4ll_set_address(link->ipv4ll, &link->network->ipv4ll_start_address);
+ /* 3. If KeepConfiguration=dhcp, use a foreign IPv4LL address. */
+ if (!FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP))
+ return 0;
+
+ SET_FOREACH(a, link->addresses) {
+ if (a->source != NETWORK_CONFIG_SOURCE_FOREIGN)
+ continue;
+ if (a->family != AF_INET)
+ continue;
+ if (!in4_addr_is_link_local_dynamic(&a->in_addr.in))
+ continue;
+
+ r = sd_ipv4ll_set_address(link->ipv4ll, &a->in_addr.in);
+ if (r < 0)
+ return r;
+
+ /* Make sure the address is not removed by link_drop_unmanaged_addresses(). */
+ a->source = NETWORK_CONFIG_SOURCE_IPV4LL;
+ return 0;
+ }
+
return 0;
}