Browse Source

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@
OPENBSD_6_7
otto 4 years ago
parent
commit
c1869dec59
5 changed files with 26 additions and 13 deletions
  1. +13
    -3
      src/usr.sbin/ntpd/constraint.c
  2. +2
    -1
      src/usr.sbin/ntpd/control.c
  3. +2
    -2
      src/usr.sbin/ntpd/ntp.c
  4. +3
    -2
      src/usr.sbin/ntpd/ntpd.c
  5. +6
    -5
      src/usr.sbin/ntpd/ntpd.h

+ 13
- 3
src/usr.sbin/ntpd/constraint.c View File

@ -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) {


+ 2
- 1
src/usr.sbin/ntpd/control.c View File

@ -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;


+ 2
- 2
src/usr.sbin/ntpd/ntp.c View File

@ -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;


+ 3
- 2
src/usr.sbin/ntpd/ntpd.c View File

@ -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");


+ 6
- 5
src/usr.sbin/ntpd/ntpd.h View File

@ -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 {


Loading…
Cancel
Save