Browse Source

do not log tiny local clock drifts; w/ help from Joerg Sonnenberger <joerg@britannica.bec.de>; henning@ ok

OPENBSD_3_7
mickey 19 years ago
parent
commit
7d3cbb5271
3 changed files with 18 additions and 4 deletions
  1. +11
    -1
      src/usr.sbin/ntpd/ntpd.8
  2. +5
    -2
      src/usr.sbin/ntpd/ntpd.c
  3. +2
    -1
      src/usr.sbin/ntpd/ntpd.h

+ 11
- 1
src/usr.sbin/ntpd/ntpd.8 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: ntpd.8,v 1.10 2004/11/02 18:00:38 henning Exp $
.\" $OpenBSD: ntpd.8,v 1.11 2004/12/06 20:57:17 mickey Exp $
.\" .\"
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
.\" .\"
@ -41,6 +41,16 @@ as described in RFC 1305.
uses the uses the
.Xr adjtime 2 .Xr adjtime 2
system call to correct the local system time without causing time jumps. system call to correct the local system time without causing time jumps.
Adjustments larger then 128ms are logged using
.Xr syslog 3 .
The threshold value is chosen to avoid local clock drift thrash the log files.
Should
.Nm
be started with
.Fl d
option all calls to
.Xr adjtime 2
will be logged.
.Pp .Pp
.Nm .Nm
is usually started at boot time, and can be enabled by is usually started at boot time, and can be enabled by


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.24 2004/11/10 11:27:54 henning Exp $ */
/* $OpenBSD: ntpd.c,v 1.25 2004/12/06 20:57:17 mickey Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -306,8 +306,11 @@ ntpd_adjtime(double d)
{ {
struct timeval tv; struct timeval tv;
if (d >= (double)LOG_NEGLIGEE / 1000)
log_info("adjusting local clock by %fs", d);
else
log_debug("adjusting local clock by %fs", d);
d_to_tv(d, &tv); d_to_tv(d, &tv);
log_info("adjusting local clock by %fs", d);
if (adjtime(&tv, NULL) == -1) if (adjtime(&tv, NULL) == -1)
log_warn("adjtime failed"); log_warn("adjtime failed");
} }


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.45 2004/12/06 16:52:33 mickey Exp $ */
/* $OpenBSD: ntpd.h,v 1.46 2004/12/06 20:57:17 mickey Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -52,6 +52,7 @@
#define QUERYTIME_MAX 15 /* single query might take n secs max */ #define QUERYTIME_MAX 15 /* single query might take n secs max */
#define OFFSET_ARRAY_SIZE 8 #define OFFSET_ARRAY_SIZE 8
#define SETTIME_MIN_OFFSET 180 /* min offset for settime at start */ #define SETTIME_MIN_OFFSET 180 /* min offset for settime at start */
#define LOG_NEGLIGEE 128 /* negligible drift to not log (ms) */
enum client_state { enum client_state {
STATE_NONE, STATE_NONE,


Loading…
Cancel
Save