From da2d33e9a84baa7325503440099dd8f1e567cdd4 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 20 Jan 2017 13:17:45 +0100 Subject: [PATCH] ntp: fix time smoothing in interleaved mode When the server's transmit timestamp was updated with a kernel/HW timestamp, it didn't include the time smoothing offset. If the offset was larger than one second, the update failed and clients using the interleaved mode received less accurate timestamps. If the update succeeded, the clients received timestamps that were not adjusted for the time smoothing offset, which added an error of up to 0.5s/1s to their measured offset/delay. Fix the update to include the smoothing offset in the new timestamp. --- ntp_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ntp_core.c b/ntp_core.c index 48ae3d1..014f999 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -2036,6 +2036,9 @@ NCR_ProcessTxUnknown(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_a if (log_index < 0) return; + if (SMT_IsEnabled() && NTP_LVM_TO_MODE(message->lvm) == MODE_SERVER) + UTI_AddDoubleToTimespec(&tx_ts->ts, SMT_GetOffset(&tx_ts->ts), &tx_ts->ts); + CLG_GetNtpTimestamps(log_index, &local_ntp_rx, &local_ntp_tx); UTI_Ntp64ToTimespec(local_ntp_tx, &local_tx.ts);