mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
sd-dhcp-client: correct dhcpv4 renew/rebind retransmit timeouts
Use the request timeout algorithm specified in RFC2131 section 4.4.5 for handling timed out RENEW and REBIND requests. This changes behavior, as previously only 2 RENEW and 2 REBIND requests were sent, no matter how long the lease lifetime. Now, requests are send according to the RFC, which results in starting with a timeout of 1/2 the t1 or t2 period, and halving the timeout for each retry down to a minimum of 60 seconds. Fixes: #17909
This commit is contained in:
parent
b0d7d8063c
commit
c24288d21e
@ -1227,7 +1227,6 @@ static int client_timeout_resend(
|
|||||||
DHCP_CLIENT_DONT_DESTROY(client);
|
DHCP_CLIENT_DONT_DESTROY(client);
|
||||||
usec_t next_timeout;
|
usec_t next_timeout;
|
||||||
uint64_t time_now;
|
uint64_t time_now;
|
||||||
uint32_t time_left;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
@ -1241,19 +1240,11 @@ static int client_timeout_resend(
|
|||||||
switch (client->state) {
|
switch (client->state) {
|
||||||
|
|
||||||
case DHCP_STATE_RENEWING:
|
case DHCP_STATE_RENEWING:
|
||||||
time_left = (client->lease->t2 - client->lease->t1) / 2;
|
next_timeout = client_compute_reacquisition_timeout(time_now, client->t2_time);
|
||||||
if (time_left < 60)
|
|
||||||
time_left = 60;
|
|
||||||
|
|
||||||
next_timeout = time_now + time_left * USEC_PER_SEC;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_REBINDING:
|
case DHCP_STATE_REBINDING:
|
||||||
time_left = (client->lease->lifetime - client->lease->t2) / 2;
|
next_timeout = client_compute_reacquisition_timeout(time_now, client->expire_time);
|
||||||
if (time_left < 60)
|
|
||||||
time_left = 60;
|
|
||||||
|
|
||||||
next_timeout = time_now + time_left * USEC_PER_SEC;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_REBOOTING:
|
case DHCP_STATE_REBOOTING:
|
||||||
@ -1279,6 +1270,7 @@ static int client_timeout_resend(
|
|||||||
|
|
||||||
client->attempt++;
|
client->attempt++;
|
||||||
next_timeout = time_now + ((UINT64_C(1) << MIN(client->attempt, (uint64_t) 6)) - 1) * USEC_PER_SEC;
|
next_timeout = time_now + ((UINT64_C(1) << MIN(client->attempt, (uint64_t) 6)) - 1) * USEC_PER_SEC;
|
||||||
|
next_timeout += (random_u32() & 0x1fffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DHCP_STATE_STOPPED:
|
case DHCP_STATE_STOPPED:
|
||||||
@ -1286,8 +1278,6 @@ static int client_timeout_resend(
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
next_timeout += (random_u32() & 0x1fffff);
|
|
||||||
|
|
||||||
r = event_reset_time(client->event, &client->timeout_resend,
|
r = event_reset_time(client->event, &client->timeout_resend,
|
||||||
clock_boottime_or_monotonic(),
|
clock_boottime_or_monotonic(),
|
||||||
next_timeout, 10 * USEC_PER_MSEC,
|
next_timeout, 10 * USEC_PER_MSEC,
|
||||||
|
Loading…
Reference in New Issue
Block a user