]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: attach sd-event in link_load() when creating link dhcp_client or ipv4ll
authorDan Streetman <ddstreet@canonical.com>
Mon, 23 Mar 2020 21:34:17 +0000 (17:34 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 Mar 2020 16:49:08 +0000 (17:49 +0100)
Commit 08c588d18b1e337f856e6541f3f711be48718279 moved attachment of the
sd-event into creation of the dhcp_client or ipv4ll in dhcp4_configure()
or ipv4ll_configure(), but these can also be created in link_load(),
so that creation needs to also perform sd-event attachment.

Without this, dhcp_client or ipv4ll created in link_load() will not have
an ->event and will fail assertion, causing networkd to fail, e.g.:

Assertion 'client->event' failed at src/libsystemd-network/sd-dhcp-client.c:1283, function client_start_delayed(). Ignoring.
ens2: Could not acquire DHCPv4 lease: Invalid argument
ens2: Failed

src/network/networkd-link.c

index d7845760c5e0004ec9e93a17a12d71e524e31c40..f38cc9f3cfda30ef2e13b09022464eebc92edded 100644 (file)
@@ -3487,6 +3487,10 @@ network_file_fail:
                 if (r < 0)
                         return log_link_error_errno(link, r, "Failed to create DHCPv4 client: %m");
 
+                r = sd_dhcp_client_attach_event(link->dhcp_client, NULL, 0);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Failed to attach DHCPv4 event: %m");
+
                 r = sd_dhcp_client_set_request_address(link->dhcp_client, &address.in);
                 if (r < 0)
                         return log_link_error_errno(link, r, "Failed to set initial DHCPv4 address %s: %m", dhcp4_address);
@@ -3505,6 +3509,10 @@ dhcp4_address_fail:
                 if (r < 0)
                         return log_link_error_errno(link, r, "Failed to create IPv4LL client: %m");
 
+                r = sd_ipv4ll_attach_event(link->ipv4ll, NULL, 0);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Failed to attach IPv4LL event: %m");
+
                 r = sd_ipv4ll_set_address(link->ipv4ll, &address.in);
                 if (r < 0)
                         return log_link_error_errno(link, r, "Failed to set initial IPv4LL address %s: %m", ipv4ll_address);