From: Yu Watanabe Date: Wed, 21 Aug 2024 01:31:34 +0000 (+0900) Subject: sd-dhcp-client: actually restart daemon after sending DECLINE message X-Git-Tag: v257-rc1~665^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22c864d88556186a82b525b009c6dc5599a87e9b;p=thirdparty%2Fsystemd.git sd-dhcp-client: actually restart daemon after sending DECLINE message client_stop() sets DHCP_STATE_STOPPED to client->state, thus the server never restarted. --- diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 1a1499fa2c9..41638ac7150 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -2260,15 +2260,13 @@ int sd_dhcp_client_send_decline(sd_dhcp_client *client) { log_dhcp_client(client, "DECLINE"); - client_stop(client, SD_DHCP_CLIENT_EVENT_STOP); - - if (client->state != DHCP_STATE_STOPPED) { - r = sd_dhcp_client_start(client); - if (r < 0) - return r; - } + /* This function is mostly called when the acquired address conflicts with another host. + * Restarting the daemon to acquire another address. */ + r = client_restart(client); + if (r < 0) + return r; - return 0; + return 1; /* sent and restarted. */ } int sd_dhcp_client_stop(sd_dhcp_client *client) {