diff options
Diffstat (limited to '')
-rw-r--r-- | src/network/networkd-dhcp4.c | 14 | ||||
-rw-r--r-- | src/network/networkd-ipv4ll.c | 15 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 19b9a3ecba..f22bc3954c 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -1173,15 +1173,9 @@ static int dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) { return 0; } - if (link->ipv4ll) { + if (link->ipv4ll && !sd_ipv4ll_is_running(link->ipv4ll)) { log_link_debug(link, "DHCP client is stopped. Acquiring IPv4 link-local address"); - if (in4_addr_is_set(&link->network->ipv4ll_start_address)) { - r = sd_ipv4ll_set_address(link->ipv4ll, &link->network->ipv4ll_start_address); - if (r < 0) - return log_link_warning_errno(link, r, "Could not set IPv4 link-local start address: %m"); - } - r = sd_ipv4ll_start(link->ipv4ll); if (r < 0 && r != -ESTALE) /* On exit, we cannot and should not start sd-ipv4ll. */ return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m"); @@ -1260,12 +1254,6 @@ static int dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) { if (link->ipv4ll && !sd_ipv4ll_is_running(link->ipv4ll)) { log_link_debug(link, "Problems acquiring DHCP lease, acquiring IPv4 link-local address"); - if (in4_addr_is_set(&link->network->ipv4ll_start_address)) { - r = sd_ipv4ll_set_address(link->ipv4ll, &link->network->ipv4ll_start_address); - if (r < 0) - return log_link_warning_errno(link, r, "Could not set IPv4 link-local start address: %m"); - } - r = sd_ipv4ll_start(link->ipv4ll); if (r < 0) return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m"); diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c index ea960593bb..648f20d596 100644 --- a/src/network/networkd-ipv4ll.c +++ b/src/network/networkd-ipv4ll.c @@ -174,6 +174,17 @@ static int ipv4ll_check_mac(sd_ipv4ll *ll, const struct ether_addr *mac, void *u return link_get_by_hw_addr(m, &hw_addr, NULL) >= 0; } +static int ipv4ll_set_address(Link *link) { + assert(link); + assert(link->network); + assert(link->ipv4ll); + + if (!in4_addr_is_set(&link->network->ipv4ll_start_address)) + return 0; + + return sd_ipv4ll_set_address(link->ipv4ll, &link->network->ipv4ll_start_address); +} + int ipv4ll_configure(Link *link) { uint64_t seed; int r; @@ -201,6 +212,10 @@ int ipv4ll_configure(Link *link) { return r; } + r = ipv4ll_set_address(link); + if (r < 0) + return r; + r = sd_ipv4ll_set_mac(link->ipv4ll, &link->hw_addr.ether); if (r < 0) return r; |