summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ntpd
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2019-06-16 07:36:25 +0000
committerotto <otto@openbsd.org>2019-06-16 07:36:25 +0000
commit09f868ac31319ac0261f9267159af6aeaa67572f (patch)
tree4d0ffec450d1a49d32f77333a7692b036cc43598 /usr.sbin/ntpd
parentacctkey indirection is unnecessary, just pass authority->account (diff)
downloadwireguard-openbsd-09f868ac31319ac0261f9267159af6aeaa67572f.tar.xz
wireguard-openbsd-09f868ac31319ac0261f9267159af6aeaa67572f.zip
Be more aggressive retrying dns while in settime mode. The constraint
engine does not know if we're in startup mode, so use a small interval the first few times there.
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r--usr.sbin/ntpd/client.c9
-rw-r--r--usr.sbin/ntpd/constraint.c6
-rw-r--r--usr.sbin/ntpd/ntp.c4
-rw-r--r--usr.sbin/ntpd/ntpd.h6
4 files changed, 18 insertions, 7 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index 990d34b0b70..4566b59cacf 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.107 2019/06/09 08:40:54 otto Exp $ */
+/* $OpenBSD: client.c,v 1.108 2019/06/16 07:36:25 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -129,8 +129,11 @@ client_query(struct ntp_peer *p)
int val;
if (p->addr == NULL && client_nextaddr(p) == -1) {
- set_next(p, MAXIMUM(SETTIME_TIMEOUT,
- scale_interval(INTERVAL_QUERY_AGGRESSIVE)));
+ if (conf->settime)
+ set_next(p, INTERVAL_AUIO_DNSFAIL);
+ else
+ set_next(p, MAXIMUM(SETTIME_TIMEOUT,
+ scale_interval(INTERVAL_QUERY_AGGRESSIVE)));
return (0);
}
diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c
index 804d79a693f..f1af7fa602a 100644
--- a/usr.sbin/ntpd/constraint.c
+++ b/usr.sbin/ntpd/constraint.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: constraint.c,v 1.45 2019/06/09 08:40:54 otto Exp $ */
+/* $OpenBSD: constraint.c,v 1.46 2019/06/16 07:36:25 otto Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -157,7 +157,9 @@ constraint_query(struct constraint *cstr)
/* Proceed and query the time */
break;
case STATE_DNS_TEMPFAIL:
- if (now > cstr->last + CONSTRAINT_RETRY_INTERVAL) {
+ if (now > cstr->last + (cstr->dnstries >= TRIES_AUTO_DNSFAIL ?
+ CONSTRAINT_RETRY_INTERVAL : INTERVAL_AUIO_DNSFAIL)) {
+ cstr->dnstries++;
/* Retry resolving the address */
constraint_init(cstr);
return 0;
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 3c77e6fa4fa..9e7fee5c4cb 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.154 2019/06/12 05:04:45 otto Exp $ */
+/* $OpenBSD: ntp.c,v 1.155 2019/06/16 07:36:25 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -520,6 +520,8 @@ ntp_dispatch_imsg_dns(void)
if (dlen == 0) { /* no data -> temp error */
log_warnx("DNS lookup tempfail");
peer->state = STATE_DNS_TEMPFAIL;
+ if (++conf->tmpfail > TRIES_AUTO_DNSFAIL)
+ priv_settime(0);
break;
}
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index c80d3cd9f3f..da3936b3db5 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.142 2019/06/12 05:04:45 otto Exp $ */
+/* $OpenBSD: ntpd.h,v 1.143 2019/06/16 07:36:25 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -69,6 +69,8 @@
#define FILTER_ADJFREQ 0x01 /* set after doing adjfreq */
#define AUTO_REPLIES 4 /* # of ntp replies we want for auto */
#define AUTO_THRESHOLD 60 /* dont bother auto setting < this */
+#define INTERVAL_AUIO_DNSFAIL 1 /* DNS tmpfail interval for auto */
+#define TRIES_AUTO_DNSFAIL 4 /* DNS tmpfail quick retries */
#define SENSOR_DATA_MAXAGE (15*60)
@@ -199,6 +201,7 @@ struct constraint {
struct imsgbuf ibuf;
time_t last;
time_t constraint;
+ int dnstries;
};
struct ntp_conf_sensor {
@@ -241,6 +244,7 @@ struct ntpd_conf {
u_int constraint_errors;
u_int8_t *ca;
size_t ca_len;
+ int tmpfail;
};
struct ctl_show_status {