summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorckuethe <ckuethe@openbsd.org>2009-06-04 23:39:45 +0000
committerckuethe <ckuethe@openbsd.org>2009-06-04 23:39:45 +0000
commit61fdcd24f45e8334516d68eee5d9299d1589f53f (patch)
treed2b6d6643fea9ff32cd9a98ff716ccc1d46d62a6
parentAdd the notion of an "ephemeral" popup, so we can flag a window (diff)
downloadwireguard-openbsd-61fdcd24f45e8334516d68eee5d9299d1589f53f.tar.xz
wireguard-openbsd-61fdcd24f45e8334516d68eee5d9299d1589f53f.zip
After calling adjfreq to correct the clock's rate, measure and fix the clock
offset. This avoids future frequency adjustments based on measurements of a clock that was being adjusted. End result: more stable clock and better frequency convergence. Also, fix a mis-ordered structure member while I'm here. ok henning
-rw-r--r--usr.sbin/ntpd/ntp.c8
-rw-r--r--usr.sbin/ntpd/ntpd.h6
2 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 7e9eff3b92c..4144bd7afa2 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.110 2009/01/26 11:51:50 henning Exp $ */
+/* $OpenBSD: ntp.c,v 1.111 2009/06/04 23:39:45 ckuethe Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -530,6 +530,11 @@ priv_adjfreq(double offset)
if (!conf->status.synced)
return;
+ if (conf->filters & FILTER_ADJFREQ){
+ conf->filters &= ~FILTER_ADJFREQ;
+ return;
+ }
+
conf->freq.samples++;
if (conf->freq.samples <= 0)
@@ -558,6 +563,7 @@ priv_adjfreq(double offset)
freq = -MAX_FREQUENCY_ADJUST;
imsg_compose(ibuf_main, IMSG_ADJFREQ, 0, 0, &freq, sizeof(freq));
+ conf->filters |= FILTER_ADJFREQ;
conf->freq.xy = 0.0;
conf->freq.x = 0.0;
conf->freq.y = 0.0;
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index 42bc0734e66..86829098f0e 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.100 2009/05/13 15:08:10 stevesk Exp $ */
+/* $OpenBSD: ntpd.h,v 1.101 2009/06/04 23:39:46 ckuethe Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -62,6 +62,7 @@
#define REPORT_INTERVAL (24*60*60) /* interval between status reports */
#define MAX_SEND_ERRORS 3 /* max send errors before reconnect */
+#define FILTER_ADJFREQ 0x01 /* set after doing adjfreq */
#define SENSOR_DATA_MAXAGE (15*60)
#define SENSOR_QUERY_INTERVAL 30
@@ -171,11 +172,12 @@ struct ntpd_conf {
TAILQ_HEAD(ntp_conf_sensors, ntp_conf_sensor) ntp_conf_sensors;
struct ntp_status status;
struct ntp_freq freq;
+ u_int32_t scale;
u_int8_t listen_all;
u_int8_t settime;
u_int8_t debug;
- u_int32_t scale;
u_int8_t noaction;
+ u_int8_t filters;
};
struct buf {