From 86626521923f584a91d8c860941d34ae64afce37 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 3 Nov 2016 08:06:26 +0100 Subject: [PATCH] ntp: disable presend in symmetric and interleaved modes The presend packet can't be used in symmetric and interleaved modes as it breaks the protocol with unexpected packets. --- doc/chrony.conf.adoc | 3 +++ ntp_core.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 95693a2..d95949a 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -202,6 +202,9 @@ presend 9 when the polling interval is 512 seconds or more, an extra NTP client packet will be sent to the server a short time (4 seconds) before making the actual measurement. ++ +The *presend* option cannot be used in the *peer* directive or with the +*xleave* option. *minstratum* _stratum_::: When the synchronisation source is selected from available sources, sources with lower stratum are normally slightly preferred. This option can be used to diff --git a/ntp_core.c b/ntp_core.c index 066077a..5299f8f 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -498,7 +498,12 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar result->min_stratum = params->min_stratum; if (result->min_stratum >= NTP_MAX_STRATUM) result->min_stratum = NTP_MAX_STRATUM - 1; + + /* Presend doesn't work in symmetric and interleaved modes */ result->presend_minpoll = params->presend_minpoll; + if (result->presend_minpoll && + (result->mode != MODE_CLIENT || result->interleaved)) + result->presend_minpoll = 0; result->max_delay = params->max_delay; result->max_delay_ratio = params->max_delay_ratio;