From 2c47602c336edc745771bd56faa0d45744fcae09 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 21 Jun 2018 17:37:31 +0200 Subject: [PATCH] ntp: allow sub-second maxpoll Remove the maxpoll-specific limit and allow both minpoll and maxpoll to be set to a negative value. --- ntp_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ntp_core.c b/ntp_core.c index fa2f762..cebaa20 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -264,8 +264,7 @@ static ARR_Instance broadcasts; #define MAX_MAXDELAYDEVRATIO 1.0e6 /* Minimum and maximum allowed poll interval */ -#define MIN_MINPOLL -4 -#define MIN_MAXPOLL 0 +#define MIN_POLL -4 #define MAX_POLL 24 /* Enable sub-second polling intervals only when the peer delay is not @@ -540,12 +539,13 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar result->interleaved = params->interleaved; result->minpoll = params->minpoll; - if (result->minpoll < MIN_MINPOLL) + if (result->minpoll < MIN_POLL) result->minpoll = SRC_DEFAULT_MINPOLL; else if (result->minpoll > MAX_POLL) result->minpoll = MAX_POLL; + result->maxpoll = params->maxpoll; - if (result->maxpoll < MIN_MAXPOLL) + if (result->maxpoll < MIN_POLL) result->maxpoll = SRC_DEFAULT_MAXPOLL; else if (result->maxpoll > MAX_POLL) result->maxpoll = MAX_POLL; @@ -2349,7 +2349,7 @@ NCR_SetConnectivity(NCR_Instance inst, SRC_Connectivity connectivity) void NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll) { - if (new_minpoll < MIN_MINPOLL || new_minpoll > MAX_POLL) + if (new_minpoll < MIN_POLL || new_minpoll > MAX_POLL) return; inst->minpoll = new_minpoll; LOG(LOGS_INFO, "Source %s new minpoll %d", UTI_IPToString(&inst->remote_addr.ip_addr), new_minpoll); @@ -2362,7 +2362,7 @@ NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll) void NCR_ModifyMaxpoll(NCR_Instance inst, int new_maxpoll) { - if (new_maxpoll < MIN_MAXPOLL || new_maxpoll > MAX_POLL) + if (new_maxpoll < MIN_POLL || new_maxpoll > MAX_POLL) return; inst->maxpoll = new_maxpoll; LOG(LOGS_INFO, "Source %s new maxpoll %d", UTI_IPToString(&inst->remote_addr.ip_addr), new_maxpoll);