summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/sensors.c
diff options
context:
space:
mode:
authorChris Kuethe <ckuethe@cvs.openbsd.org>2007-09-12 21:08:47 +0000
committerChris Kuethe <ckuethe@cvs.openbsd.org>2007-09-12 21:08:47 +0000
commit385475b05fe47915df1ee94e073424bc8784ca38 (patch)
treed44f7f75d008d52d0af5afe6b68152c958d6e8ef /usr.sbin/ntpd/sensors.c
parent3d78660185aa2b921a612f1f9d14cbac860184af (diff)
Add a knob to compensate for a refclock that is early or late. Based on a
diff from Maurice Janssen. Manpage help from jmc and Maurice, other nits from deraadt and otto. ok deraadt, otto
Diffstat (limited to 'usr.sbin/ntpd/sensors.c')
-rw-r--r--usr.sbin/ntpd/sensors.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c
index dde110f8f72..0e0c69f63ff 100644
--- a/usr.sbin/ntpd/sensors.c
+++ b/usr.sbin/ntpd/sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensors.c,v 1.33 2007/08/04 02:58:02 ckuethe Exp $ */
+/* $OpenBSD: sensors.c,v 1.34 2007/09/12 21:08:46 ckuethe Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
@@ -121,13 +121,15 @@ sensor_add(int sensordev, char *dxname)
s->next = getmonotime();
s->weight = cs->weight;
+ s->correction = cs->correction;
if ((s->device = strdup(dxname)) == NULL)
fatal("sensor_add strdup");
s->sensordevid = sensordev;
TAILQ_INSERT_TAIL(&conf->ntp_sensors, s, entry);
- log_debug("sensor %s added", s->device);
+ log_debug("sensor %s added (weight %d, correction %.6f)",
+ s->device, s->weight, s->correction / 1e6);
}
void
@@ -176,7 +178,8 @@ sensor_query(struct ntp_sensor *s)
* sensor.value = TS - TD in ns
* if value is positive, system time is ahead
*/
- s->offsets[s->shift].offset = (sensor.value / -1e9) - getoffset();
+ s->offsets[s->shift].offset = (sensor.value / -1e9) - getoffset() +
+ (s->correction / 1e6);
s->offsets[s->shift].rcvd = sensor.tv.tv_sec;
s->offsets[s->shift].good = 1;