]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: randomize address selection on all source replacements
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 22 May 2023 09:58:41 +0000 (11:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 23 May 2023 07:33:48 +0000 (09:33 +0200)
If the resolver orders addresses by IP family, there is more than one
address in the preferred IP family, and they are all reachable, but
not selectable (e.g. falsetickers in a small pool which cannot remove
them from DNS), chronyd is unable to switch to addresses in the other IP
family as it follows the resolver's order.

Enable randomization of the address selection for all source
replacements and not just replacement of (unreachable) tentative
sources. If the system doesn't have connectivity in the other family,
the addresses will be skipped and no change in behavior should be
observed.

ntp_sources.c

index 91267dcc24fb6ad380a43a9694fe9445fd63c20f..f10b3302d8ee6044d6c83f6dafc76e63778263d8 100644 (file)
@@ -988,11 +988,11 @@ resolve_source_replacement(SourceRecord *record, int refreshment)
 
   us = MallocNew(struct UnresolvedSource);
   us->name = Strdup(record->name);
-  /* If there never was a valid reply from this source (e.g. it was a bad
-     replacement), ignore the order of addresses from the resolver to not get
-     stuck to a pair of addresses if the order doesn't change, or a group of
-     IPv4/IPv6 addresses if the resolver prefers inaccessible IP family */
-  us->random_order = record->tentative;
+  /* Ignore the order of addresses from the resolver to not get
+     stuck with a pair of unreachable or otherwise unusable servers
+     (e.g. falsetickers) in case the order doesn't change, or a group
+     of servers if they are ordered by IP family */
+  us->random_order = 1;
   us->refreshment = refreshment;
   us->pool_id = INVALID_POOL;
   us->address = *record->remote_addr;