From 9d1c1505b9bd876b4a2b9fd03407e6e65d014f3a Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 18 Feb 2020 13:45:13 +0100 Subject: [PATCH] ntp: repeat resolving until all pool sources are resolved When resolving of a pool name succeeds, don't remove the remaining unresolved sources, i.e. try to get all maxsources (default 4) sources, even if it takes multiple DNS requests. --- doc/chrony.conf.adoc | 16 +++++++++------- ntp_sources.c | 8 ++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 54c6d6c..0f6a281 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -269,16 +269,18 @@ which might change over time. + All options valid in the <> directive can be used in this directive too. There is one option specific to the *pool* directive: -*maxsources* sets the maximum number of sources that can be used from the pool, -the default value is 4. + -On start, when the pool name is resolved, *chronyd* will add up to 16 sources, -one for each resolved address. When the number of sources from which at least -one valid reply was received reaches the number specified by the *maxsources* -option, the other sources will be removed. When a pool source is unreachable, +*maxsources* _sources_::: +This option sets the desired number of sources to be used from the pool. +*chronyd* will repeatedly try to resolve the name until it gets this number of +sources responding to requests. The default value is 4 and the maximum value is +16. ++ +:: +When an NTP source is unreachable, marked as a falseticker, or has a distance larger than the limit set by the <> directive, *chronyd* will try to replace the -source with a newly resolved address from the pool. +source with a newly resolved address of the name. + An example of the *pool* directive is + diff --git a/ntp_sources.c b/ntp_sources.c index 036ba5e..eb99e6d 100644 --- a/ntp_sources.c +++ b/ntp_sources.c @@ -424,10 +424,6 @@ process_resolved_name(struct UnresolvedSource *us, IPAddr *ip_addrs, int n_addrs break; } } - - /* Remove pool sources that didn't get an address */ - if (us->pool != INVALID_POOL) - remove_pool_sources(us->pool, 0, 1); } /* ================================================== */ @@ -485,9 +481,9 @@ name_resolve_handler(DNS_Status status, int n_addrs, IPAddr *ip_addrs, void *any next = us->next; - /* Don't repeat the resolving if it didn't (temporarily) fail, it was a + /* Don't repeat the resolving if it (permanently) failed, it was a replacement of a real address, or all addresses are already resolved */ - if (status != DNS_TryAgain || UTI_IsIPReal(&us->address.ip_addr) || is_resolved(us)) + if (status == DNS_Failure || UTI_IsIPReal(&us->address.ip_addr) || is_resolved(us)) remove_unresolved_source(us); resolving_source = next;