summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2021-03-28 17:25:21 +0000
committerkrw <krw@openbsd.org>2021-03-28 17:25:21 +0000
commit1e3e204afb9be07f86f57ea9b3e93211a062b7a7 (patch)
treebc95cc1bb44cd2d70a0cb7ea1ec8497386a67d42 /sbin
parentConvert remaining timers (lease renew, rebind, expiry) to (diff)
downloadwireguard-openbsd-1e3e204afb9be07f86f57ea9b3e93211a062b7a7.tar.xz
wireguard-openbsd-1e3e204afb9be07f86f57ea9b3e93211a062b7a7.zip
Now that the real time and monotonic time streams don't
cross flip CLOCK_REALTIME to CLOCK_MONOTONIC. Suggested by cheloha@, millert@, otto@ at various stages in the time_t -> timespec conversion.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c30
-rw-r--r--sbin/dhclient/dispatch.c8
-rw-r--r--sbin/dhclient/kroute.c6
3 files changed, 22 insertions, 22 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 5043be023b0..dee2f0e0e9b 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.714 2021/03/28 16:23:05 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.715 2021/03/28 17:25:21 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -793,7 +793,7 @@ state_reboot(struct interface_info *ifi)
make_request(ifi, ifi->active);
ifi->destination.s_addr = INADDR_BROADCAST;
- clock_gettime(CLOCK_REALTIME, &ifi->first_sending);
+ clock_gettime(CLOCK_MONOTONIC, &ifi->first_sending);
timespecadd(&ifi->first_sending, &reboot_intvl, &ifi->reboot_timeout);
ifi->interval = 0;
@@ -814,7 +814,7 @@ state_init(struct interface_info *ifi)
ifi->destination.s_addr = INADDR_BROADCAST;
ifi->state = S_SELECTING;
- clock_gettime(CLOCK_REALTIME, &ifi->first_sending);
+ clock_gettime(CLOCK_MONOTONIC, &ifi->first_sending);
timespecadd(&ifi->first_sending, &offer_intvl, &ifi->offer_timeout);
ifi->select_timeout = ifi->offer_timeout;
ifi->interval = 0;
@@ -845,7 +845,7 @@ state_selecting(struct interface_info *ifi)
}
ifi->destination.s_addr = INADDR_BROADCAST;
- clock_gettime(CLOCK_REALTIME, &ifi->first_sending);
+ clock_gettime(CLOCK_MONOTONIC, &ifi->first_sending);
ifi->interval = 0;
/*
@@ -900,7 +900,7 @@ process_offer(struct interface_info *ifi, struct option_data *options,
struct timespec now;
struct client_lease *lease;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
lease = packet_to_lease(ifi, options);
if (lease != NULL) {
@@ -1024,7 +1024,7 @@ bind_lease(struct interface_info *ifi)
int rslt, seen;
tick_msg("lease", TICK_SUCCESS);
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
lease = apply_defaults(ifi->offer);
get_lease_timeouts(ifi, lease);
@@ -1160,7 +1160,7 @@ state_bound(struct interface_info *ifi)
else
dest->s_addr = INADDR_BROADCAST;
- clock_gettime(CLOCK_REALTIME, &ifi->first_sending);
+ clock_gettime(CLOCK_MONOTONIC, &ifi->first_sending);
ifi->interval = 0;
ifi->state = S_RENEWING;
@@ -1448,7 +1448,7 @@ send_discover(struct interface_info *ifi)
struct timespec now;
ssize_t rslt;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
if (timespeccmp(&now, &ifi->offer_timeout, >=)) {
state_panic(ifi);
return;
@@ -1506,7 +1506,7 @@ send_request(struct interface_info *ifi)
ssize_t rslt;
cancel_timeout(ifi);
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
switch (ifi->state) {
case S_REBOOTING:
@@ -2492,7 +2492,7 @@ take_charge(struct interface_info *ifi, int routefd, char *leasespath)
struct rt_msghdr rtm;
int fd, nfds;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
resend = now;
timespecadd(&now, &max_timeout, &stop);
@@ -2514,7 +2514,7 @@ take_charge(struct interface_info *ifi, int routefd, char *leasespath)
rtm.rtm_flags = RTF_UP | RTF_PROTO3;
for (fd = -1; fd == -1 && quit != TERMINATE;) {
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
if (timespeccmp(&now, &stop, >=))
fatalx("failed to take charge");
@@ -2657,7 +2657,7 @@ get_lease_timeouts(struct interface_info *ifi, struct client_lease *lease)
{
struct timespec now, interval;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
timespecclear(&interval);
interval.tv_sec = lease_expiry(lease);
@@ -2685,7 +2685,7 @@ tick_msg(const char *preamble, int action)
static int linkup, preamble_sent, sleeping;
int printmsg;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
if (!timespecisset(&stop)) {
preamble_sent = 0;
@@ -2802,7 +2802,7 @@ propose_release(struct interface_info *ifi)
struct rt_msghdr rtm;
int nfds, routefd, rtfilter;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
timespecadd(&now, &max_timeout, &stop);
if ((routefd = socket(AF_ROUTE, SOCK_RAW, AF_INET)) == -1)
@@ -2834,7 +2834,7 @@ propose_release(struct interface_info *ifi)
log_debug("%s: sent RTM_PROPOSAL to release lease", log_procname);
while (quit == 0) {
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
if (timespeccmp(&now, &stop, >=))
break;
timespecsub(&stop, &now, &timeout);
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 8d8eda6d83d..5951ba8efd3 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.171 2021/03/09 14:32:24 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.172 2021/03/28 17:25:21 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -96,7 +96,7 @@ dispatch(struct interface_info *ifi, int routefd)
while (quit == 0 || quit == RESTART) {
if (quit == RESTART) {
quit = 0;
- clock_gettime(CLOCK_REALTIME, &ifi->link_timeout);
+ clock_gettime(CLOCK_MONOTONIC, &ifi->link_timeout);
timespecadd(&ifi->link_timeout, &link_intvl, &ifi->link_timeout);
free(ifi->configured);
ifi->configured = NULL;
@@ -106,7 +106,7 @@ dispatch(struct interface_info *ifi, int routefd)
state_preboot(ifi);
}
if (timespecisset(&ifi->timeout)) {
- clock_gettime(CLOCK_REALTIME, &timeout);
+ clock_gettime(CLOCK_MONOTONIC, &timeout);
if (timespeccmp(&timeout, &ifi->timeout, >=)) {
func = ifi->timeout_func;
cancel_timeout(ifi);
@@ -307,7 +307,7 @@ set_timeout(struct interface_info *ifi, time_t secs,
{
struct timespec now;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
timespecclear(&ifi->timeout);
ifi->timeout.tv_sec = secs;
timespecadd(&ifi->timeout, &now, &ifi->timeout);
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index cb67612e10d..d85425f316f 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.196 2021/03/04 10:56:47 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.197 2021/03/28 17:25:21 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -585,7 +585,7 @@ default_route_index(int rdomain, int routefd)
iov[2].iov_len = sizeof(sin);
pid = getpid();
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
timespecclear(&timeout);
timeout.tv_sec = 3;
timespecadd(&now, &timeout, &stop);
@@ -600,7 +600,7 @@ default_route_index(int rdomain, int routefd)
}
for (;;) {
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
if (timespeccmp(&stop, &now, <=))
break;
timespecsub(&stop, &now, &timeout);