]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: add options to set minsamples/maxsamples of hwclock
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 8 Aug 2018 12:03:35 +0000 (14:03 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 9 Aug 2018 12:52:08 +0000 (14:52 +0200)
conf.c
conf.h
doc/chrony.conf.adoc
ntp_io_linux.c

diff --git a/conf.c b/conf.c
index ef6db084744f464ed78f9e8e4749d4d42372e4b5..85a7f2e9679eb4a25bd857147d80a6ff8b80affc 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1291,6 +1291,8 @@ parse_hwtimestamp(char *line)
   iface = ARR_GetNewElement(hwts_interfaces);
   iface->name = Strdup(p);
   iface->minpoll = 0;
+  iface->min_samples = 2;
+  iface->max_samples = 16;
   iface->nocrossts = 0;
   iface->rxfilter = CNF_HWTS_RXFILTER_ANY;
   iface->precision = 100.0e-9;
@@ -1300,9 +1302,15 @@ parse_hwtimestamp(char *line)
   for (p = line; *p; line += n, p = line) {
     line = CPS_SplitWord(line);
 
-    if (!strcasecmp(p, "minpoll")) {
+    if (!strcasecmp(p, "maxsamples")) {
+      if (sscanf(line, "%d%n", &iface->max_samples, &n) != 1)
+        break;
+    } else if (!strcasecmp(p, "minpoll")) {
       if (sscanf(line, "%d%n", &iface->minpoll, &n) != 1)
         break;
+    } else if (!strcasecmp(p, "minsamples")) {
+      if (sscanf(line, "%d%n", &iface->min_samples, &n) != 1)
+        break;
     } else if (!strcasecmp(p, "precision")) {
       if (sscanf(line, "%lf%n", &iface->precision, &n) != 1)
         break;
diff --git a/conf.h b/conf.h
index 25c98e1ee74b85ec0bca49f7bd0053175dea02b1..43217fc6a97b388eb297860112a6f707c7d8325d 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -128,6 +128,8 @@ typedef enum {
 typedef struct {
   char *name;
   int minpoll;
+  int min_samples;
+  int max_samples;
   int nocrossts;
   CNF_HwTs_RxFilter rxfilter;
   double precision;
index 864990db9afbbefa3e1e996608ac195a1a15e948..4a39c21bff00c1d71de40e9e7dcbf83580bed07d 100644 (file)
@@ -1945,6 +1945,12 @@ It's defined as a power of two. It should correspond to the minimum polling
 interval of all NTP sources and the minimum expected polling interval of NTP
 clients. The default value is 0 (1 second) and the minimum value is -6 (1/64th
 of a second).
+*minsamples* _samples_:::
+This option specifies the minimum number of readings kept for tracking of the
+NIC clock. The default value is 2.
+*maxsamples* _samples_:::
+This option specifies the maximum number of readings kept for tracking of the
+NIC clock. The default value is 16.
 *precision* _precision_:::
 This option specifies the assumed precision of reading of the NIC clock. The
 default value is 100e-9 (100 nanoseconds).
index ad7b6eebf8e546efa700ba0484911ff3e36fab7e..819792aa47cb1b7bfc746e3ce3650b6bef6ee086 100644 (file)
@@ -236,8 +236,8 @@ add_interface(CNF_HwTsInterface *conf_iface)
   iface->tx_comp = conf_iface->tx_comp;
   iface->rx_comp = conf_iface->rx_comp;
 
-  iface->clock = HCL_CreateInstance(0, 16, UTI_Log2ToDouble(MAX(conf_iface->minpoll,
-                                                                MIN_PHC_POLL)));
+  iface->clock = HCL_CreateInstance(conf_iface->min_samples, conf_iface->max_samples,
+                                    UTI_Log2ToDouble(MAX(conf_iface->minpoll, MIN_PHC_POLL)));
 
   LOG(LOGS_INFO, "Enabled HW timestamping %son %s",
       ts_config.rx_filter == HWTSTAMP_FILTER_NONE ? "(TX only) " : "", iface->name);