]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: apply HW TX/RX compensation to system time
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 15 Jun 2017 09:16:57 +0000 (11:16 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Jun 2017 13:29:01 +0000 (15:29 +0200)
Apply the compensation to the cooked local time instead of HW time. This
might make a difference when the HW clock has a large frequency error.

ntp_io_linux.c

index 5a506773a95de096ae96525d08e3b697ed63324a..736aea54430bccbfb57f1e87b4f29cb3a1242301 100644 (file)
@@ -451,14 +451,14 @@ process_hw_timestamp(struct Interface *iface, struct timespec *hw_ts,
     UTI_AddDoubleToTimespec(hw_ts, rx_correction, hw_ts);
   }
 
-  if (!rx_ntp_length && iface->tx_comp)
-    UTI_AddDoubleToTimespec(hw_ts, iface->tx_comp, hw_ts);
-  else if (rx_ntp_length && iface->rx_comp)
-    UTI_AddDoubleToTimespec(hw_ts, -iface->rx_comp, hw_ts);
-
   if (!HCL_CookTime(iface->clock, hw_ts, &ts, &local_err))
     return;
 
+  if (!rx_ntp_length && iface->tx_comp)
+    UTI_AddDoubleToTimespec(&ts, iface->tx_comp, &ts);
+  else if (rx_ntp_length && iface->rx_comp)
+    UTI_AddDoubleToTimespec(&ts, -iface->rx_comp, &ts);
+
   ts_delay = UTI_DiffTimespecsToDouble(&local_ts->ts, &ts);
 
   if (fabs(ts_delay) > MAX_TS_DELAY) {