sd-dhcp-client: simply enter renewing/rebinding state send DHCPREQUEST on T1/T2

It is not necessary to enable another timer event source to send
DHCPREQUEST from the T1/T2 timer event source. Just call the callback
function for sending message.

Also, T1 hits only we have a bound lease. Drop spurious conditions.
This commit is contained in:
Yu Watanabe
2026-04-24 07:40:07 +09:00
parent ffc3d5f812
commit f0b9b679ff
+6 -16
View File
@@ -1353,38 +1353,28 @@ static int client_timeout_expire(sd_event_source *s, uint64_t usec, void *userda
static int client_timeout_t2(sd_event_source *s, uint64_t usec, void *userdata) {
sd_dhcp_client *client = ASSERT_PTR(userdata);
DHCP_CLIENT_DONT_DESTROY(client);
int r;
/* Explicitly close the unicast socket opened during renewing. On success path, the socket will be
* closed anyway on sending broadcast DHCPREQUEST, but let's explicitly close it here for failure
* path to ignore all unicast replies from now on. */
client->receive_message = sd_event_source_disable_unref(client->receive_message);
client_set_state(client, DHCP_STATE_REBINDING);
client->discover_attempt = 0;
client->request_attempt = 0;
r = client_initialize_time_events(client);
if (r < 0)
client_stop(client, r);
return 0;
return client_timeout_resend(s, usec, userdata);
}
static int client_timeout_t1(sd_event_source *s, uint64_t usec, void *userdata) {
sd_dhcp_client *client = ASSERT_PTR(userdata);
DHCP_CLIENT_DONT_DESTROY(client);
int r;
if (client->lease)
client_set_state(client, DHCP_STATE_RENEWING);
else if (client->state != DHCP_STATE_INIT)
client_set_state(client, DHCP_STATE_INIT_REBOOT);
client_set_state(client, DHCP_STATE_RENEWING);
client->discover_attempt = 0;
client->request_attempt = 0;
r = client_initialize_time_events(client);
if (r < 0)
client_stop(client, r);
return 0;
return client_timeout_resend(s, usec, userdata);
}
static int dhcp_option_parse_and_verify(