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