-/* $OpenBSD: dhclient.c,v 1.697 2021/02/21 18:16:59 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.698 2021/02/22 02:19:03 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
void
state_reboot(struct interface_info *ifi)
{
- struct client_lease *lease;
+ const struct timespec reboot_intvl = {config->reboot_interval, 0};
+ struct timespec now;
+ struct client_lease *lease;
cancel_timeout(ifi);
make_request(ifi, ifi->active);
ifi->destination.s_addr = INADDR_BROADCAST;
- time(&ifi->first_sending);
+ clock_gettime(CLOCK_REALTIME, &now);
+ ifi->first_sending = now.tv_sec;
+ timespecadd(&now, &reboot_intvl, &ifi->reboot_timeout);
ifi->interval = 0;
send_request(ifi);
{
struct sockaddr_in destination;
struct in_addr from;
+ struct timespec now;
ssize_t rslt;
time_t cur_time, interval;
cancel_timeout(ifi);
- time(&cur_time);
+ clock_gettime(CLOCK_REALTIME, &now);
+ cur_time = now.tv_sec;
if (log_getverbose())
tick_msg("lease", TICK_WAIT);
switch (ifi->state) {
case S_REBOOTING:
- if (interval > config->reboot_interval)
+ if (timespeccmp(&now, &ifi->reboot_timeout, >=))
ifi->state = S_INIT;
else {
destination.sin_addr.s_addr = INADDR_BROADCAST;
-/* $OpenBSD: dhcpd.h,v 1.292 2021/02/21 18:16:59 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.293 2021/02/22 02:19:03 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
int sent_packet_length;
uint32_t xid;
struct timespec timeout;
+ struct timespec reboot_timeout;
time_t expiry, rebind;
void (*timeout_func)(struct interface_info *);
uint16_t secs;