From: Miroslav Lichvar Date: Thu, 15 Jun 2017 09:16:57 +0000 (+0200) Subject: ntp: apply HW TX/RX compensation to system time X-Git-Tag: 3.2-pre1~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db93180ce14a55abdc3c820129b0199142a1a050;p=thirdparty%2Fchrony.git ntp: apply HW TX/RX compensation to system time 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. --- diff --git a/ntp_io_linux.c b/ntp_io_linux.c index 5a506773..736aea54 100644 --- a/ntp_io_linux.c +++ b/ntp_io_linux.c @@ -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) {