rpms/ntp/F-11 ntp-4.2.4p7-freqmode.patch, NONE, 1.1 ntp-4.2.4p7-daemonpll.patch, 1.1, 1.2 ntp.spec, 1.89, 1.90
Miroslav Lichvar
mlichvar at fedoraproject.org
Thu May 28 18:51:50 UTC 2009
Author: mlichvar
Update of /cvs/pkgs/rpms/ntp/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv29201
Modified Files:
ntp-4.2.4p7-daemonpll.patch ntp.spec
Added Files:
ntp-4.2.4p7-freqmode.patch
Log Message:
- fix frequency calculation when starting with no drift file
- reduce phase adjustments beyond Allan intercept in daemon PLL
ntp-4.2.4p7-freqmode.patch:
--- NEW FILE ntp-4.2.4p7-freqmode.patch ---
diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter.c.freqmode ntp-4.2.4p7/ntpd/ntp_loopfilter.c
--- ntp-4.2.4p7/ntpd/ntp_loopfilter.c.freqmode 2009-05-28 15:19:30.000000000 +0200
+++ ntp-4.2.4p7/ntpd/ntp_loopfilter.c 2009-05-28 17:21:30.000000000 +0200
@@ -133,6 +133,7 @@ u_long sys_clocktime; /* last system cl
u_long pps_control; /* last pps update */
u_long sys_tai; /* UTC offset from TAI (s) */
static void rstclock P((int, u_long, double)); /* transition function */
+static double direct_freq(double, u_long); /* calculate frequency directly */
#ifdef KERNEL_PLL
struct timex ntv; /* kernel API parameters */
@@ -359,8 +360,7 @@ local_clock(
if (mu < clock_minstep)
return (0);
- clock_frequency = (fp_offset - clock_offset) /
- mu;
+ clock_frequency = direct_freq(fp_offset, mu);
/* fall through to S_SPIK */
@@ -451,16 +451,16 @@ local_clock(
/*
* In S_FREQ state ignore updates until the stepout
- * threshold. After that, correct the phase and
- * frequency and switch to S_SYNC state.
+ * threshold. After that, compute the new frequency, but
+ * do not adjust the phase or frequency until the next
+ * update.
*/
case S_FREQ:
if (mu < clock_minstep)
return (0);
- clock_frequency = (fp_offset - clock_offset) /
- mu;
- rstclock(S_SYNC, peer->epoch, fp_offset);
+ clock_frequency = direct_freq(fp_offset, mu);
+ rstclock(S_SYNC, peer->epoch, 0);
break;
/*
@@ -590,8 +590,7 @@ local_clock(
*/
if (clock_frequency != 0) {
ntv.modes |= MOD_FREQUENCY;
- ntv.freq = (int32)((clock_frequency +
- drift_comp) * 65536e6);
+ ntv.freq = (int32)(clock_frequency * 65536e6);
}
ntv.esterror = (u_int32)(clock_jitter * 1e6);
ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
@@ -837,6 +836,43 @@ rstclock(
last_offset = clock_offset = offset;
}
+/*
+ * calc_freq - calculate frequency directly
+ *
+ * This is very carefully done. When the offset is first computed at the
+ * first update, a residual frequency component results. Subsequently,
+ * updates are suppresed until the end of the measurement interval while
+ * the offset is amortized. At the end of the interval the frequency is
+ * calculated from the current offset, residual offset, length of the
+ * interval and residual frequency component. At the same time the
+ * frequenchy file is armed for update at the next hourly stats.
+ */
+static double
+direct_freq(
+ double fp_offset,
+ u_long mu
+ )
+{
+
+#ifdef KERNEL_PLL
+ /*
+ * If the kernel is enabled, we need the residual offset to
+ * calculate the frequency correction.
+ */
+ if (pll_control && kern_enable) {
+ memset(&ntv, 0, sizeof(ntv));
+ ntp_adjtime(&ntv);
+#ifdef STA_NANO
+ clock_offset = ntv.offset / 1e9;
+#else /* STA_NANO */
+ clock_offset = ntv.offset / 1e6;
+#endif /* STA_NANO */
+ drift_comp = ntv.freq / 65536e6;
+ }
+#endif /* KERNEL_PLL */
+ return (fp_offset - clock_offset) / mu + drift_comp;
+}
+
int huffpuff_enabled()
{
ntp-4.2.4p7-daemonpll.patch:
Index: ntp-4.2.4p7-daemonpll.patch
===================================================================
RCS file: /cvs/pkgs/rpms/ntp/F-11/ntp-4.2.4p7-daemonpll.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- ntp-4.2.4p7-daemonpll.patch 19 May 2009 15:06:13 -0000 1.1
+++ ntp-4.2.4p7-daemonpll.patch 28 May 2009 18:51:49 -0000 1.2
@@ -14,3 +14,20 @@ diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter
dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll);
plladj = fp_offset * etemp / (dtemp * dtemp);
rstclock(S_SYNC, peer->epoch, fp_offset);
+@@ -801,13 +805,10 @@ adj_host_clock(
+
+ /*
+ * Implement the phase and frequency adjustments. The gain
+- * factor (denominator) is not allowed to increase beyond the
+- * Allan intercept. It doesn't make sense to average phase noise
+- * beyond this point and it helps to damp residual offset at the
+- * longer poll intervals.
++ * factor (denominator) increases with poll interval, so is
++ * dominated by the FLL above the Allan intercept.
+ */
+- adjustment = clock_offset / (CLOCK_PLL * min(ULOGTOD(sys_poll),
+- allan_xpt));
++ adjustment = clock_offset / (CLOCK_PLL * ULOGTOD(sys_poll));
+ clock_offset -= adjustment;
+ adj_systime(adjustment + drift_comp);
+ #endif /* LOCKCLOCK */
Index: ntp.spec
===================================================================
RCS file: /cvs/pkgs/rpms/ntp/F-11/ntp.spec,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -p -r1.89 -r1.90
--- ntp.spec 19 May 2009 15:06:13 -0000 1.89
+++ ntp.spec 28 May 2009 18:51:50 -0000 1.90
@@ -1,7 +1,7 @@
Summary: The NTP daemon and utilities
Name: ntp
Version: 4.2.4p7
-Release: 1%{?dist}
+Release: 2%{?dist}
# primary license (COPYRIGHT) : MIT
# ElectricFence/ (not used) : GPLv2
# kernel/sys/ppsclock.h (not used) : BSD with advertising
@@ -98,6 +98,8 @@ Patch27: ntp-4.2.4p5-driftonexit.patch
Patch28: ntp-4.2.4p7-nano.patch
# allow minpoll 3 as in 4.2.5
Patch29: ntp-4.2.4p7-minpoll.patch
+# fix frequency mode, backported from 4.2.5
+Patch30: ntp-4.2.4p7-freqmode.patch
URL: http://www.ntp.org
Requires(post): /sbin/chkconfig
@@ -178,6 +180,7 @@ This package contains NTP documentation
%patch27 -p1 -b .driftonexit
%patch28 -p1 -b .nano
%patch29 -p1 -b .minpoll
+%patch30 -p1 -b .freqmode
# clock_gettime needs -lrt
sed -i.gettime 's|^LIBS = @LIBS@|& -lrt|' ntp{d,q,dc,date}/Makefile.in
@@ -357,6 +360,10 @@ fi
%{ntpdocdir}/html
%changelog
+* Thu May 28 2009 Miroslav Lichvar <mlichvar at redhat.com> 4.2.4p7-2
+- fix frequency calculation when starting with no drift file
+- reduce phase adjustments beyond Allan intercept in daemon PLL
+
* Tue May 19 2009 Miroslav Lichvar <mlichvar at redhat.com> 4.2.4p7-1
- update to 4.2.4p7 (CVE-2009-1252)
- improve PLL response when kernel discipline is disabled
More information about the fedora-extras-commits
mailing list