summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2020-02-12 19:14:57 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2020-02-12 19:14:57 +0000
commitf9e9cafd15d9d3cc0291b5af608482bf8308d0b8 (patch)
treeb6866eb1734a9e8a0a0fabf3f4eed3fefdd04e16 /usr.sbin/ntpd
parent42929787739b02239f2f550d2006e6cffd64c8ad (diff)
If constraints are configured but do not work for whatever reason ntpd
does not work. Make that more clear in the log and ntpdctl -s status. report by and ok benno@
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r--usr.sbin/ntpd/constraint.c16
-rw-r--r--usr.sbin/ntpd/control.c3
-rw-r--r--usr.sbin/ntpd/ntp.c4
-rw-r--r--usr.sbin/ntpd/ntpd.c5
-rw-r--r--usr.sbin/ntpd/ntpd.h11
5 files changed, 26 insertions, 13 deletions
diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c
index 656142aec00..3df3a1aa9e5 100644
--- a/usr.sbin/ntpd/constraint.c
+++ b/usr.sbin/ntpd/constraint.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: constraint.c,v 1.48 2019/07/16 14:15:40 otto Exp $ */
+/* $OpenBSD: constraint.c,v 1.49 2020/02/12 19:14:56 otto Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -695,8 +695,9 @@ constraint_msg_result(u_int32_t id, u_int8_t *data, size_t len)
void
constraint_msg_close(u_int32_t id, u_int8_t *data, size_t len)
{
- struct constraint *cstr;
- int fail;
+ struct constraint *cstr, *tmp;
+ int fail, cnt;
+ static int total_fails;
if ((cstr = constraint_byid(id)) == NULL) {
log_warnx("IMSG_CONSTRAINT_CLOSE with invalid constraint id");
@@ -715,6 +716,15 @@ constraint_msg_close(u_int32_t id, u_int8_t *data, size_t len)
" received in time, next query %ds",
log_sockaddr((struct sockaddr *)
&cstr->addr->ss), CONSTRAINT_SCAN_INTERVAL);
+
+ cnt = 0;
+ TAILQ_FOREACH(tmp, &conf->constraints, entry)
+ cnt++;
+ if (cnt > 0 && ++total_fails >= cnt &&
+ conf->constraint_median == 0) {
+ log_warnx("constrainst configured but none available");
+ total_fails = 0;
+ }
}
if (fail || cstr->state < STATE_QUERY_SENT) {
diff --git a/usr.sbin/ntpd/control.c b/usr.sbin/ntpd/control.c
index 7c1f0e1c852..751e9cb4c66 100644
--- a/usr.sbin/ntpd/control.c
+++ b/usr.sbin/ntpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.17 2019/07/10 05:53:37 otto Exp $ */
+/* $OpenBSD: control.c,v 1.18 2020/02/12 19:14:56 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -329,6 +329,7 @@ build_show_status(struct ctl_show_status *cs)
cs->synced = conf->status.synced;
cs->stratum = conf->status.stratum;
cs->clock_offset = getoffset() * 1000.0;
+ cs->constraints = !TAILQ_EMPTY(&conf->constraints);
cs->constraint_median = conf->constraint_median;
cs->constraint_last = conf->constraint_last;
cs->constraint_errors = conf->constraint_errors;
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 02c5b6bd913..ea9a4e92274 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.162 2019/11/11 06:32:52 otto Exp $ */
+/* $OpenBSD: ntp.c,v 1.163 2020/02/12 19:14:56 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -228,7 +228,7 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv)
memset(pfd, 0, sizeof(*pfd) * pfd_elms);
memset(idx2peer, 0, sizeof(*idx2peer) * idx2peer_elms);
- nextaction = getmonotime() + 3600;
+ nextaction = getmonotime() + 900;
pfd[PFD_PIPE_MAIN].fd = ibuf_main->fd;
pfd[PFD_PIPE_MAIN].events = POLLIN;
pfd[PFD_PIPE_DNS].fd = ibuf_dns->fd;
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index d54d35c8b25..e015d1d0933 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.128 2019/11/11 06:32:52 otto Exp $ */
+/* $OpenBSD: ntpd.c,v 1.129 2020/02/12 19:14:56 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -810,7 +810,8 @@ show_status_msg(struct imsg *imsg)
printf(" (%d errors)",
cstatus->constraint_errors);
printf(", ");
- }
+ } else if (cstatus->constraints)
+ printf("constraints configured but none available, ");
if (cstatus->peercnt + cstatus->sensorcnt == 0)
printf("no peers and no sensors configured\n");
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index 04940e76e2a..208d19ccdfe 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.148 2019/11/11 06:32:52 otto Exp $ */
+/* $OpenBSD: ntpd.h,v 1.149 2020/02/12 19:14:56 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -254,16 +254,17 @@ struct ntpd_conf {
};
struct ctl_show_status {
+ time_t constraint_median;
+ time_t constraint_last;
+ double clock_offset;
u_int peercnt;
u_int sensorcnt;
u_int valid_peers;
u_int valid_sensors;
+ u_int constraint_errors;
u_int8_t synced;
u_int8_t stratum;
- double clock_offset;
- time_t constraint_median;
- time_t constraint_last;
- u_int constraint_errors;
+ u_int8_t constraints;
};
struct ctl_show_peer {