|
|
6e16f6 |
diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.clockstate ntp-4.2.6p5/ntpd/ntp_loopfilter.c
|
|
|
6e16f6 |
--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.clockstate 2015-12-04 13:42:45.807689201 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c 2015-12-04 15:21:34.252296997 +0100
|
|
|
6e16f6 |
@@ -189,6 +189,51 @@ init_loopfilter(void)
|
|
|
6e16f6 |
clock_jitter = LOGTOD(sys_precision);
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+#ifdef KERNEL_PLL
|
|
|
6e16f6 |
+/*
|
|
|
6e16f6 |
+ * ntp_adjtime_wrapper - call ntp_adjtime() and print errors and clock state
|
|
|
6e16f6 |
+ * changes related to leap seconds
|
|
|
6e16f6 |
+ */
|
|
|
6e16f6 |
+static int
|
|
|
6e16f6 |
+ntp_adjtime_wrapper(struct timex *timex)
|
|
|
6e16f6 |
+{
|
|
|
6e16f6 |
+ static int last_ret = TIME_OK;
|
|
|
6e16f6 |
+ int ret;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ ret = ntp_adjtime(timex);
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (ret < 0) {
|
|
|
6e16f6 |
+ msyslog(LOG_ERR, "ntp_adjtime() failed: %s", strerror(errno));
|
|
|
6e16f6 |
+ return ret;
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (ret == last_ret || ret == TIME_ERROR)
|
|
|
6e16f6 |
+ return ret;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ switch (ret) {
|
|
|
6e16f6 |
+ case TIME_OK:
|
|
|
6e16f6 |
+ if (last_ret != TIME_INS && last_ret != TIME_DEL)
|
|
|
6e16f6 |
+ break;
|
|
|
6e16f6 |
+ msyslog(LOG_INFO, "kernel leap second %s cancelled",
|
|
|
6e16f6 |
+ last_ret == TIME_INS ? "insertion" : "deletion");
|
|
|
6e16f6 |
+ break;
|
|
|
6e16f6 |
+ case TIME_INS:
|
|
|
6e16f6 |
+ msyslog(LOG_INFO, "kernel reports leap second insertion scheduled");
|
|
|
6e16f6 |
+ break;
|
|
|
6e16f6 |
+ case TIME_DEL:
|
|
|
6e16f6 |
+ msyslog(LOG_INFO, "kernel reports leap second deletion scheduled");
|
|
|
6e16f6 |
+ break;
|
|
|
6e16f6 |
+ case TIME_WAIT:
|
|
|
6e16f6 |
+ msyslog(LOG_INFO, "kernel reports leap second has occurred");
|
|
|
6e16f6 |
+ break;
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ last_ret = ret;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ return ret;
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+#endif
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* local_clock - the NTP logical clock loop filter.
|
|
|
6e16f6 |
*
|
|
|
6e16f6 |
@@ -566,7 +611,7 @@ local_clock(
|
|
|
6e16f6 |
* the pps. In any case, fetch the kernel offset,
|
|
|
6e16f6 |
* frequency and jitter.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
- if (ntp_adjtime(&ntv) == TIME_ERROR) {
|
|
|
6e16f6 |
+ if (ntp_adjtime_wrapper(&ntv) == TIME_ERROR) {
|
|
|
6e16f6 |
if (!(ntv.status & STA_PPSSIGNAL))
|
|
|
6e16f6 |
report_event(EVNT_KERN, NULL,
|
|
|
6e16f6 |
"PPS no signal");
|
|
|
6e16f6 |
@@ -598,7 +643,7 @@ local_clock(
|
|
|
6e16f6 |
loop_tai = sys_tai;
|
|
|
6e16f6 |
ntv.modes = MOD_TAI;
|
|
|
6e16f6 |
ntv.constant = sys_tai;
|
|
|
6e16f6 |
- ntp_adjtime(&ntv;;
|
|
|
6e16f6 |
+ ntp_adjtime_wrapper(&ntv;;
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
#endif /* STA_NANO */
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
@@ -775,7 +820,7 @@ direct_freq(
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
if (pll_control && kern_enable) {
|
|
|
6e16f6 |
memset(&ntv, 0, sizeof(ntv));
|
|
|
6e16f6 |
- ntp_adjtime(&ntv;;
|
|
|
6e16f6 |
+ ntp_adjtime_wrapper(&ntv;;
|
|
|
6e16f6 |
#ifdef STA_NANO
|
|
|
6e16f6 |
clock_offset = ntv.offset / 1e9;
|
|
|
6e16f6 |
#else /* STA_NANO */
|
|
|
6e16f6 |
@@ -811,7 +856,7 @@ set_freq(
|
|
|
6e16f6 |
memset(&ntv, 0, sizeof(ntv));
|
|
|
6e16f6 |
ntv.modes = MOD_FREQUENCY;
|
|
|
6e16f6 |
ntv.freq = DTOFREQ(drift_comp);
|
|
|
6e16f6 |
- ntp_adjtime(&ntv;;
|
|
|
6e16f6 |
+ ntp_adjtime_wrapper(&ntv;;
|
|
|
6e16f6 |
snprintf(tbuf, sizeof(tbuf), "kernel %.3f PPM",
|
|
|
6e16f6 |
drift_comp * 1e6);
|
|
|
6e16f6 |
report_event(EVNT_FSET, NULL, tbuf);
|
|
|
6e16f6 |
@@ -905,7 +950,7 @@ loop_config(
|
|
|
6e16f6 |
pll_control = 0;
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
if (sigsetjmp(env, 1) == 0)
|
|
|
6e16f6 |
- ntp_adjtime(&ntv;;
|
|
|
6e16f6 |
+ ntp_adjtime_wrapper(&ntv;;
|
|
|
6e16f6 |
if ((sigaction(SIGSYS, &sigsys,
|
|
|
6e16f6 |
(struct sigaction *)NULL))) {
|
|
|
6e16f6 |
msyslog(LOG_ERR,
|
|
|
6e16f6 |
@@ -913,7 +958,7 @@ loop_config(
|
|
|
6e16f6 |
pll_control = 0;
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
#else /* SIGSYS */
|
|
|
6e16f6 |
- ntp_adjtime(&ntv;;
|
|
|
6e16f6 |
+ ntp_adjtime_wrapper(&ntv;;
|
|
|
6e16f6 |
#endif /* SIGSYS */
|
|
|
6e16f6 |
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
@@ -964,7 +1009,7 @@ loop_config(
|
|
|
6e16f6 |
memset((char *)&ntv, 0, sizeof(ntv));
|
|
|
6e16f6 |
ntv.modes = MOD_STATUS;
|
|
|
6e16f6 |
ntv.status = STA_UNSYNC;
|
|
|
6e16f6 |
- ntp_adjtime(&ntv;;
|
|
|
6e16f6 |
+ ntp_adjtime_wrapper(&ntv;;
|
|
|
6e16f6 |
report_event(EVNT_KERN, NULL,
|
|
|
6e16f6 |
"kernel time sync disabledx");
|
|
|
6e16f6 |
}
|