]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: improve maxdelayratio test
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 25 Aug 2017 12:57:25 +0000 (14:57 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 28 Aug 2017 12:27:14 +0000 (14:27 +0200)
Similarly to the maxdelaydevratio test, include in the maximum delay
dispersion which accumulated in the interval since the last sample.
Also, enable the test for symmetric associations.

doc/chrony.conf.adoc
ntp_core.c
test/simulation/118-maxdelay

index 612bc00d172f1222ef832bf3fd250db393ba6204..6b65445c24a72ccc383d79ce3bc43d87d4725d22 100644 (file)
@@ -115,8 +115,7 @@ round-trip delay of 0.3 seconds or more should be ignored. The default value is
 This option is similar to the maxdelay option above. *chronyd* keeps a record
 of the minimum round-trip delay amongst the previous measurements that it has
 buffered. If a measurement has a round trip delay that is greater than the
-maxdelayratio times the minimum delay, it will be rejected. This option does
-not work in the *peer* directive.
+maxdelayratio times the minimum delay, it will be rejected.
 *maxdelaydevratio* _ratio_:::
 If a measurement has a ratio of the increase in the round-trip delay from the
 minimum delay amongst the previous measurements to the standard deviation of
index af475165e84b5e8399865f852657ca9d953a4d9b..d73111fbcf88f0340b7ef6d9308764428431f42d 100644 (file)
@@ -1325,6 +1325,30 @@ check_packet_auth(NTP_Packet *pkt, int length,
 
 /* ================================================== */
 
+static int
+check_delay_ratio(NCR_Instance inst, SST_Stats stats,
+                struct timespec *sample_time, double delay)
+{
+  double last_sample_ago, predicted_offset, min_delay, skew, std_dev;
+  double max_delay;
+
+  if (inst->max_delay_ratio < 1.0 ||
+      !SST_GetDelayTestData(stats, sample_time, &last_sample_ago,
+                            &predicted_offset, &min_delay, &skew, &std_dev))
+    return 1;
+
+  max_delay = min_delay * inst->max_delay_ratio +
+              last_sample_ago * (skew + LCL_GetMaxClockError());
+
+  if (delay <= max_delay)
+    return 1;
+
+  DEBUG_LOG("maxdelayratio: delay=%e max_delay=%e", delay, max_delay);
+  return 0;
+}
+
+/* ================================================== */
+
 static int
 check_delay_dev_ratio(NCR_Instance inst, SST_Stats stats,
                       struct timespec *sample_time, double offset, double delay)
@@ -1582,9 +1606,7 @@ receive_packet(NCR_Instance inst, NTP_Local_Address *local_addr,
     /* Test B requires in client mode that the ratio of the round trip delay
        to the minimum one currently in the stats data register is less than an
        administrator-defined value */
-    testB = inst->max_delay_ratio <= 1.0 ||
-            !(inst->mode == MODE_CLIENT &&
-              (delay - dispersion) / SST_MinRoundTripDelay(stats) > inst->max_delay_ratio);
+    testB = check_delay_ratio(inst, stats, &sample_time, delay);
 
     /* Test C requires that the ratio of the increase in delay from the minimum
        one in the stats data register to the standard deviation of the offsets
index 18fcdfa31093391567114a42c694cae7a28dff46..22b9a502c975fa8bf8a1ccce52a8bfd223cf954e 100755 (executable)
@@ -18,7 +18,7 @@ check_source_selection || test_fail
 check_packet_interval || test_fail
 check_sync || test_fail
 
-for client_server_options in "maxpoll 6 maxdelay 2e-5" "maxpoll 6 maxdelayratio 1.001"; do
+for client_server_options in "maxpoll 6 maxdelay 2e-5"; do
        run_test || test_fail
        check_chronyd_exit || test_fail
        check_packet_interval || test_fail