* for retransmission delays, timeout should start at 4s then double
* each attempt with max of 64s, with -1 to +1 sec of random 'fuzz' added.
* This assumes the first call will be using attempt 1. */
-static usec_t client_compute_request_timeout(usec_t now, uint64_t attempt) {
+static usec_t client_compute_request_timeout(uint64_t attempt) {
usec_t timeout = (UINT64_C(1) << MIN(attempt + 1, UINT64_C(6))) * USEC_PER_SEC;
-
- return usec_sub_signed(usec_add(now, timeout), RFC2131_RANDOM_FUZZ);
+ return usec_sub_signed(timeout, RFC2131_RANDOM_FUZZ);
}
/* RFC2131 section 4.4.5:
* of 60 seconds.
* Note that while the default T1/T2 initial times do have random 'fuzz' applied,
* the RFC sec 4.4.5 does not mention adding any fuzz to retries. */
-static usec_t client_compute_reacquisition_timeout(usec_t now, usec_t expire) {
- return now + MAX(usec_sub_unsigned(expire, now) / 2, 60 * USEC_PER_SEC);
+static usec_t client_compute_reacquisition_timeout(usec_t now_usec, usec_t expire) {
+ return MAX(usec_sub_unsigned(expire, now_usec) / 2, 60 * USEC_PER_SEC);
}
static int cmp_uint8(const uint8_t *a, const uint8_t *b) {
goto error;
client->discover_attempt++;
- next_timeout = client_compute_request_timeout(time_now, client->discover_attempt);
+ next_timeout = client_compute_request_timeout(client->discover_attempt);
break;
case DHCP_STATE_REQUESTING:
case DHCP_STATE_BOUND:
goto error;
client->request_attempt++;
- next_timeout = client_compute_request_timeout(time_now, client->request_attempt);
+ next_timeout = client_compute_request_timeout(client->request_attempt);
break;
case DHCP_STATE_STOPPED:
assert_not_reached();
}
- r = event_reset_time(client->event, &client->timeout_resend,
- CLOCK_BOOTTIME,
- next_timeout, 10 * USEC_PER_MSEC,
- client_timeout_resend, client,
- client->event_priority, "dhcp4-resend-timer", true);
+ r = event_reset_time_relative(
+ client->event, &client->timeout_resend,
+ CLOCK_BOOTTIME, next_timeout, 10 * USEC_PER_MSEC,
+ client_timeout_resend, client,
+ client->event_priority, "dhcp4-resend-timer", true);
if (r < 0)
goto error;