]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-client: actually restart daemon after sending DECLINE message
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 01:31:34 +0000 (10:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 02:45:57 +0000 (11:45 +0900)
client_stop() sets DHCP_STATE_STOPPED to client->state, thus the server
never restarted.

src/libsystemd-network/sd-dhcp-client.c

index 1a1499fa2c960fe8561f5c8acd39886d9f4f5abe..41638ac7150e64461bbea944719fde2b6b94e5e8 100644 (file)
@@ -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) {