(CC) Bug in xntp-3.5c

Ulrich Windl (Ulrich.Windl@rz.uni-regensburg.de)
Mon, 29 Apr 1996 08:25:16 +0200


(Excuse this waste of bandwidth, but this seems to be important for a
lot of people having problems with xntpd-3.5c. This message has been
sent to Dave Mills)

Still working on Linux and xntpd being a perfect combination, I think
I've found a bug in xntpd that is independent of Linux:

In ntp_loopfilter.c the drift_comp seems to be added twice for the
kernel PLL. Otherwise the code for PLL and without PLL should be
mutually exclusive. I did not find a solution without adding a new
variable. Possibly you have to apply the patch by hand, because I've
added some debugging output to my version, which I removed from the
patch; therefore the line numbers might not match with your version.

One thing that is related to Linux only is the fact that in
ntp_unixclock the tickadj is specified as "1". Despite of the fact
that this limits the offsets being written to "/etc/ntp.drift" to
roughly 70ppm (but not the PLL frequency), it is not correct for
Linux. Linux uses "500/HZ" (5 on the i386).

I don't have a DEC Alpha, but the Alpha runs with "HZ == 1000" I
think, and thus "500/HZ" would give zero. You might add the line
if (*tickadj == 0)
*tickadj = 1;

Ulrich Windl

Index: ntp_loopfilter.c
===================================================================
RCS file: /tmp/REPOS/xntp/xntpd/ntp_loopfilter.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ntp_loopfilter.c
--- ntp_loopfilter.c 1996/03/31 01:14:02 1.1.1.1
+++ ntp_loopfilter.c 1996/04/27 21:54:08
@@ -728,6 +738,7 @@
adj_frequency(freq)
s_fp freq; /* frequency (ppm) */
{
+ s_fp old_drift_comp = drift_comp;
#if defined(KERNEL_PLL)
struct timex ntv;
#endif /* KERNEL_PLL */
@@ -756,7 +767,12 @@
return;
memset((char *)&ntv, 0, sizeof ntv);
ntv.modes = MOD_FREQUENCY;
- ntv.freq = freq + drift_comp;
+ ntv.freq = freq + old_drift_comp;
(void)ntp_adjtime(&ntv);
drift_comp = ntv.freq;
#endif /* KERNEL_PLL */
Index: ntp_unixclock.c
===================================================================
RCS file: /tmp/REPOS/xntp/xntpd/ntp_unixclock.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ntp_unixclock.c
--- ntp_unixclock.c 1996/03/31 01:14:02 1.1.1.1
+++ ntp_unixclock.c 1996/04/28 19:23:12
@@ -682,6 +682,7 @@
#endif /* SYS_SOLARIS */

#ifdef SYS_LINUX
+#include <sys/param.h>
#include <sys/timex.h>
static void
clock_parms(tickadj, tick)
@@ -697,8 +698,8 @@
#endif
__adjtimex(&txc);

- *tickadj = (u_long)1; /* our adjtime is accurate */
- *tick = (u_long)txc.tick;
+ *tickadj = (u_long) (500 / HZ); /* our adjtime is accurate */
+ *tick = (u_long) txc.tick;
}
#endif /* SYS_LINUX */