From 2d4edec9f38cc851dedf344f5afc6aba04254ac2 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Apr 20 2017 16:04:52 +0000 Subject: don't drop PHC samples with zero delay --- diff --git a/chrony-phcdelay.patch b/chrony-phcdelay.patch new file mode 100644 index 0000000..d1d510e --- /dev/null +++ b/chrony-phcdelay.patch @@ -0,0 +1,33 @@ +commit abb09418b16993ecd8289dd459dff91701f4f971 +Author: Miroslav Lichvar +Date: Wed Apr 19 12:20:14 2017 +0200 + + sys_linux: don't drop PHC samples with zero delay + + When processing data from the PTP_SYS_OFFSET ioctl, the sample is + dropped when an interval between two consecutive readings of the system + clock is negative or zero, assuming the clock has been stepped between + the two readings. + + With a real PHC the interval is normally expected to be at least a + microsecond, but with a virtual PHC and a low-resolution system clock + it's possible to get two readings with the same system time. Modify the + check to drop only samples with a negative delay. + +diff --git a/sys_linux.c b/sys_linux.c +index c06112a..649afb0 100644 +--- a/sys_linux.c ++++ b/sys_linux.c +@@ -705,9 +705,11 @@ get_phc_sample(int phc_fd, double precision, struct timespec *phc_ts, + phc_tss[i] = ts2; + delays[i] = UTI_DiffTimespecsToDouble(&ts3, &ts1); + +- if (delays[i] <= 0.0) ++ if (delays[i] < 0.0) { + /* Step in the middle of a PHC reading? */ ++ DEBUG_LOG(LOGF_SysLinux, "Bad PTP_SYS_OFFSET sample delay=%e", delays[i]); + return 0; ++ } + + if (!i || delays[i] < min_delay) + min_delay = delays[i]; diff --git a/chrony.spec b/chrony.spec index 09d005c..c247852 100644 --- a/chrony.spec +++ b/chrony.spec @@ -23,6 +23,8 @@ Source10: https://github.com/mlichvar/clknetsim/archive/%{clknetsim_ver}/c Patch1: chrony-service-helper.patch # fix seccomp filter for new glibc Patch2: chrony-seccomp.patch +# don't drop PHC samples with zero delay +Patch3: chrony-phcdelay.patch BuildRequires: libcap-devel libedit-devel nss-devel pps-tools-devel %ifarch %{ix86} x86_64 %{arm} aarch64 mipsel mips64el ppc64 ppc64le s390 s390x @@ -60,6 +62,7 @@ clocks, system real-time clock or manual input as time references. %{?gitpatch:%patch0 -p1} %patch1 -p1 -b .service-helper %patch2 -p1 -b .seccomp +%patch3 -p1 -b .phcdelay %{?gitpatch: echo %{version}-%{gitpatch} > version.txt}