summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevesk <stevesk@openbsd.org>2009-02-10 16:52:09 +0000
committerstevesk <stevesk@openbsd.org>2009-02-10 16:52:09 +0000
commitd45de13aa1d4cbdb493ace55c2da747256c536b2 (patch)
tree5a9413961d32d4d323fda5385213d5e52b27cf7d
parentendservent() not needed here; ok henning@ (diff)
downloadwireguard-openbsd-d45de13aa1d4cbdb493ace55c2da747256c536b2.tar.xz
wireguard-openbsd-d45de13aa1d4cbdb493ace55c2da747256c536b2.zip
log tiny frequency adjustments at debug only.
ok henning@, 'I think I agree' otto@
-rw-r--r--usr.sbin/ntpd/ntpd.c19
-rw-r--r--usr.sbin/ntpd/ntpd.h3
2 files changed, 16 insertions, 6 deletions
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index 5459777d543..cc9befaac9a 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.63 2009/02/06 21:48:00 stevesk Exp $ */
+/* $OpenBSD: ntpd.c,v 1.64 2009/02/10 16:52:09 stevesk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -380,6 +380,7 @@ void
ntpd_adjfreq(double relfreq, int wrlog)
{
int64_t curfreq;
+ double ppmfreq;
int r;
if (adjfreq(NULL, &curfreq) == -1) {
@@ -393,10 +394,18 @@ ntpd_adjfreq(double relfreq, int wrlog)
*/
curfreq += relfreq * 1e9 * (1LL << 32);
r = writefreq(curfreq / 1e9 / (1LL << 32));
- if (wrlog)
- log_info("adjusting clock frequency by %f to %fppm%s",
- relfreq * 1e6, curfreq / 1e3 / (1LL << 32),
- r ? "" : " (no drift file)");
+ ppmfreq = relfreq * 1e6;
+ if (wrlog) {
+ if (ppmfreq >= LOG_NEGLIGIBLE_ADJFREQ ||
+ ppmfreq <= -LOG_NEGLIGIBLE_ADJFREQ)
+ log_info("adjusting clock frequency by %f to %fppm%s",
+ ppmfreq, curfreq / 1e3 / (1LL << 32),
+ r ? "" : " (no drift file)");
+ else
+ log_debug("adjusting clock frequency by %f to %fppm%s",
+ ppmfreq, curfreq / 1e3 / (1LL << 32),
+ r ? "" : " (no drift file)");
+ }
if (adjfreq(&curfreq, NULL) == -1)
log_warn("adjfreq failed");
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index cd182569e8f..4c037ab4705 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.97 2009/02/06 21:48:00 stevesk Exp $ */
+/* $OpenBSD: ntpd.h,v 1.98 2009/02/10 16:52:09 stevesk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -56,6 +56,7 @@
#define SENSOR_OFFSETS 7
#define SETTIME_TIMEOUT 15 /* max seconds to wait with -s */
#define LOG_NEGLIGIBLE_ADJTIME 32 /* negligible drift to not log (ms) */
+#define LOG_NEGLIGIBLE_ADJFREQ 0.05 /* negligible rate to not log (ppm) */
#define FREQUENCY_SAMPLES 8 /* samples for est. of permanent drift */
#define MAX_FREQUENCY_ADJUST 128e-5 /* max correction per iteration */
#define REPORT_INTERVAL (24*60*60) /* interval between status reports */