From 8df49b799fb171a69f8d9a0fc036961cafc64559 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 22 Nov 2021 15:52:01 +0100 Subject: [PATCH] ntp: suppress monotonic timestamp if smoothing is enabled Frequency transfer and time smoothing are conflicting features. Set the monotonic timestamp in the experimental extension field to zero (invalid) if time smoothing is activated. --- ntp_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ntp_core.c b/ntp_core.c index cda4c9c..fa2d5b2 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -974,7 +974,10 @@ add_ext_exp1(NTP_Packet *message, NTP_PacketInfo *info, struct timespec *rx, if (info->mode != MODE_CLIENT) { exp1.root_delay = UTI_DoubleToNtp32f28(root_delay); exp1.root_dispersion = UTI_DoubleToNtp32f28(root_dispersion); - UTI_AddDoubleToTimespec(rx, server_mono_offset, &mono_rx); + if (rx) + UTI_AddDoubleToTimespec(rx, server_mono_offset, &mono_rx); + else + UTI_ZeroTimespec(&mono_rx); UTI_GetNtp64Fuzz(&ts_fuzz, message->precision); UTI_TimespecToNtp64(&mono_rx, &exp1.mono_receive_ts, &ts_fuzz); exp1.mono_epoch = htonl(server_mono_epoch); @@ -1138,7 +1141,7 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */ if (ext_field_flags) { if (ext_field_flags & NTP_EF_FLAG_EXP1) { - if (!add_ext_exp1(&message, &info, &local_receive, + if (!add_ext_exp1(&message, &info, smooth_time ? NULL : &local_receive, our_root_delay, our_root_dispersion)) return 0; }