summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/sensors.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2019-11-10 07:32:59 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2019-11-10 07:32:59 +0000
commit34be1fed3766170255e928e0677e60683c43106b (patch)
tree22ac7267c7adcc772c9e894fee49c68a2b71027b /usr.sbin/ntpd/sensors.c
parentcabf39325a3d7e58827998d41a9474fb6579f78c (diff)
- validate sensor values against constraints
- do not restart settime timeout interval if something happens in the main event loop - apply a tight loop protection; it can be painfull on a single core machine since the process runs at maximum priority. Should only happen when a bug is introduced while developing, but prevents having to machine taken over by ntpd.
Diffstat (limited to 'usr.sbin/ntpd/sensors.c')
-rw-r--r--usr.sbin/ntpd/sensors.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c
index 6d137932928..4ca9a554065 100644
--- a/usr.sbin/ntpd/sensors.c
+++ b/usr.sbin/ntpd/sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensors.c,v 1.52 2016/09/03 11:52:06 reyk Exp $ */
+/* $OpenBSD: sensors.c,v 1.53 2019/11/10 07:32:58 otto Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
@@ -165,6 +165,7 @@ sensor_query(struct ntp_sensor *s)
{
char dxname[MAXDEVNAMLEN];
struct sensor sensor;
+ double sens_time;
if (conf->settime)
s->next = getmonotime() + SENSOR_QUERY_INTERVAL_SETTIME;
@@ -193,6 +194,18 @@ sensor_query(struct ntp_sensor *s)
return;
s->last = sensor.tv.tv_sec;
+
+ if (!TAILQ_EMPTY(&conf->constraints)) {
+ if (conf->constraint_median == 0) {
+ return;
+ }
+ sens_time = gettime() + (sensor.value / -1e9) +
+ (s->correction / 1e6);
+ if (constraint_check(sens_time) != 0) {
+ log_info("sensor %s: constraint check failed", s->device);
+ return;
+ }
+ }
/*
* TD = device time
* TS = system time