From 5e2a89d84bddb79452917d2565aa7cc59a24047e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 30 Aug 2023 17:33:01 +0900 Subject: [PATCH 1/2] sd-dhcp-client: ensure IAID and DUID being set on start After b2851e8d6287ab9bb3cd6e42395271c45ce0e377, if IAID and DUID are not set on start, calling sd_dhcp_client_set_iaid_duid_en() in client_message_init() triggers assertion, as the client is already running at the stage. Let's set IAID and DUID earlier. Fixes #28990. --- src/libsystemd-network/sd-dhcp-client.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 265750d090..21b6592037 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -870,13 +870,6 @@ static int client_message_init( if (client->request_broadcast || client->arp_type != ARPHRD_ETHER) packet->dhcp.flags = htobe16(0x8000); - /* If no client identifier exists, construct an RFC 4361-compliant one */ - if (client->client_id_len == 0) { - r = sd_dhcp_client_set_iaid_duid_en(client, /* iaid_set = */ false, /* iaid = */ 0); - if (r < 0) - return r; - } - /* Some DHCP servers will refuse to issue an DHCP lease if the Client Identifier option is not set */ r = dhcp_option_append(&packet->dhcp, optlen, &optoffset, 0, @@ -2075,6 +2068,13 @@ int sd_dhcp_client_start(sd_dhcp_client *client) { if (r < 0) return r; + /* If no client identifier exists, construct an RFC 4361-compliant one */ + if (client->client_id_len == 0) { + r = sd_dhcp_client_set_iaid_duid_en(client, /* iaid_set = */ false, /* iaid = */ 0); + if (r < 0) + return r; + } + /* RFC7844 section 3.3: SHOULD perform a complete four-way handshake, starting with a DHCPDISCOVER, to obtain a new address lease. If the client can From 3b981f742838b0890d87437f4d76b71ba8183455 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 30 Aug 2023 17:26:57 +0900 Subject: [PATCH 2/2] Revert "test-dhcp-client: add temporary workaround for assertion failure" This reverts commit 1686c884bfa846f8da87621e87870eb18dd8107c. The issue should be fixed by the previous commit. Let's drop the workaround. --- src/libsystemd-network/test-dhcp-client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index 8c16d65bbc..f3f558a358 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -522,9 +522,7 @@ static void test_addr_acq(sd_event *e) { res = sd_dhcp_client_start(client); assert_se(IN_SET(res, 0, -EINPROGRESS)); - r = sd_event_loop(e); - /* Times out since https://github.com/systemd/systemd/issues/28990 add workaorund for now */ - assert_se(r >= 0 || r == -ETIMEDOUT); + assert_se(sd_event_loop(e) >= 0); assert_se(sd_dhcp_client_set_callback(client, NULL, NULL) >= 0); assert_se(sd_dhcp_client_stop(client) >= 0);