]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-client: simplify the condition in sd_dhcp_client_get_lease()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 19 Oct 2023 14:57:44 +0000 (23:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 Oct 2023 16:54:08 +0000 (01:54 +0900)
The condition was outdated, e.g. SELECTING state does not have a lease.
See client_handle_offer() and client_enter_requesting().

The condition based on the state may become much complex in the future.
Let's use simpler condition.

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

index bc73e87b95b793cf2c879c93a6a42684ce9d59a3..6c08d2896226560e64e95291eaa61e856280d665 100644 (file)
@@ -709,7 +709,7 @@ int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v)
 int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) {
         assert_return(client, -EINVAL);
 
-        if (!IN_SET(client->state, DHCP_STATE_SELECTING, DHCP_STATE_BOUND, DHCP_STATE_RENEWING, DHCP_STATE_REBINDING))
+        if (!client->lease)
                 return -EADDRNOTAVAIL;
 
         if (ret)