]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: include maxclockerror in source selection
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 22 Feb 2018 16:30:23 +0000 (17:30 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 26 Feb 2018 12:42:04 +0000 (13:42 +0100)
In the source selection algorithm, include extra dispersion due to
maxclockerror in the root distance of sources that don't have new
samples (the last sample is older than span of all samples) to not
prefer unreachable sources with a short distance and small skew over
reachable sources for too long, and also to decrease their chances of
becoming falsetickers.

sources.c

index 67b61e739fc0c5f411515d76ce93f505e0a907a1..8aaa4a6fefc00498d6a6dbe5219683d8b100684a 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -665,6 +665,16 @@ SRC_SelectSource(SRC_Instance updated_inst)
       continue;
     }
 
+    /* Include extra dispersion in the root distance of sources that don't
+       have new samples (the last sample is older than span of all samples) */
+    if (first_sample_ago < 2.0 * si->last_sample_ago) {
+      double extra_disp = LCL_GetMaxClockError() *
+                          (2.0 * si->last_sample_ago - first_sample_ago);
+      si->root_distance += extra_disp;
+      si->lo_limit -= extra_disp;
+      si->hi_limit += extra_disp;
+    }
+
     /* Require the root distance to be below the allowed maximum */
     if (si->root_distance > max_distance) {
       sources[i]->status = SRC_BAD_DISTANCE;