summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/sd-dhcp-client.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-10-19 16:57:44 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-10-20 18:54:08 +0200
commita43f92252600599045c2309b8e839ebf0c39a614 (patch)
treee58dddd3ecf6de07bff8ee9339708494e356c71f /src/libsystemd-network/sd-dhcp-client.c
parentdhcp: split dhcp-internal.h into two (diff)
downloadsystemd-a43f92252600599045c2309b8e839ebf0c39a614.tar.xz
systemd-a43f92252600599045c2309b8e839ebf0c39a614.zip
sd-dhcp-client: simplify the condition in sd_dhcp_client_get_lease()
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.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-client.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index bc73e87b95..6c08d28962 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -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)