2.0.33: small patch for NTP v4 compatibility (long)

Ulrich Windl (wiu09524@pc3103.klinik.uni-regensburg.de)
Fri, 6 Mar 1998 10:50:37 +0100 (CET)

(the same message will go to comp.protocols.time.ntp)

Hello everybody,

I regret to have to post yet another patch to the Linux time code, but
as experiments with NTP version 4 have shown, the current
implementation of ntp_adjtime (adjtimex), one of the strictest on the
market, won't work for very high polling intervals (used in FLL
mode). Even worse, the client code did not check the syscall return
value, and the error has been undetected for a while.

On the document mentioned in the comment, Dave Mills wrote on page 24
(about ntp_adjtime (adjtimex in Linux):

"constant (rw) If selected, this member replaces the value of the
time_constant kernel variable. The value must be between zero and
MAXTC (6) defined in the timex.h header file."

In a recent EMail message, Dave Mills pointed out that MAXTC is not
used anymore, and that it should be dropped from <timex.h>. My
investigation on the subject showed that MAXTC is still used in

if (ntx.constant < 0 || ntx.constant > MAXTC)

Therefor I did leave MAXTC unchanged in <timex.h>, and removed the
requirement instead. The constant is only used for a right shift, so
that large values will finally result in a zero value. Thus there's no
danger of an overflow.

[Message #1 from Dave Mills]

Date: Tue, 3 Mar 1998 15:21:16 EST
From: Dave Mills <mills@huey.udel.edu>
To: "Kristofer T. Karas" <ktk@ktk.bidmc.harvard.edu>
Cc: juha@c3l.tyreso.se, Ulrich.Windl@rz.uni-regensburg.de, mills@udel.edu
Subject: Re: Report on using ntp-4.0.72 under Linux-2.0
Content-Length: 519
Content-Type: text
Message-ID: <199803031521.aa26332@huey.udel.edu>


If the Linux code is close to my model code in kernel.tar, you have
increased the maximum averaging time from 1024 seconds to 4096 seconds.
I doubt very much that your loop will stay locked if the room ambient
temperature changes quickly. That may be acceptable in face of better
suppression of large phase noise, but I am skeptical.

My kernel model has no MAXTC, although the original ntp_loopfilter.c
did. What's going on here?

The NTPv4 kernel model is identical to NTPv3, at least for the present.


[Message #2 from Dave Mills]

Date: Wed, 4 Mar 1998 10:17:11 EST
From: Dave Mills <mills@huey.udel.edu>
To: Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
Cc: Dave Mills <mills@huey.udel.edu>, juha@c3l.tyreso.se,
Ulrich.Windl@rz.uni-regensburg.de, mills@udel.edu
Subject: Re: Report on using ntp-4.0.72 under Linux-2.0
Content-Length: 659
Content-Type: text
Message-ID: <199803041017.aa03200@huey.udel.edu>


The intent of the original MAXTC in the reference kernel implementation
documented in kernel.tar is to vary over he range 0-6 corresponding
to a poll interval range 2^4 through 2^10. The actual values were
determined by extensive simulation, as documented in kernel.tar and
the simulator program there. The MAXTC was chosen mainly to prevent
the time constant increasing beyond 2^6 when the poll interval is
increased beyond 1024 s for modems. It probably is not a good idea to
insert additional sanity checks in the interface code (ntp_adjtime()
does not do this), as this just adds additional layers of things that
break and confuse folks.


Here is a patch against 2.0.33:

P.S. Thanks to all the other NTP hackers

--- linux/kernel/time.c.stock Sun Nov 23 18:30:14 1997
+++ linux/kernel/time.c Thu Mar 5 19:53:50 1998
@@ -20,6 +20,10 @@
* support for external PPS signal, error checking in adjtimex()
* Updated NTP code according to technical memorandum Jan '96
* "A Kernel Model for Precision Timekeeping" by Dave Mills
+ * 1998-03-05 Ulrich Windl
+ * Allow time_constant larger than MAXTC(6) for NTP v4
+ * (debated with and blessed by Dave Mills, despite of earlier work
+ * and words)

#include <linux/errno.h>
@@ -565,7 +569,7 @@

if (txc.modes & ADJ_TIMECONST) { /* p. 24 */
- if (txc.constant < 0 || txc.constant > MAXTC) {
+ if (txc.constant < 0) { /* NTP v4 uses values > 6 */
error = -EINVAL;
goto leave;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu