]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: ignore onoffline command for unresolved sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 9 Mar 2020 11:26:51 +0000 (12:26 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 9 Mar 2020 12:02:23 +0000 (13:02 +0100)
The onoffline command switches an unresolved source to the offline
status, even when the network is already up.

Ignore the onoffline command for unresolved sources to prevent sources
unexpectedly staying in the offline status, e.g. when the command is
issued from a network dispatcher script (and no other call is expected
later when the name is resolved).

ntp_sources.c

index 995da1b988f0f886a4fdc5e56b3dda20355ff8a1..dfdcff22cb382438d73a5df63aa701de2e81fe33 100644 (file)
@@ -1047,7 +1047,10 @@ NSR_SetConnectivity(IPAddr *mask, IPAddr *address, SRC_Connectivity connectivity
   for (i = 0; i < ARR_GetSize(records); i++) {
     record = get_record(i);
     if (record->remote_addr) {
-      if (address->family == IPADDR_UNSPEC ||
+      /* Ignore SRC_MAYBE_ONLINE connectivity change for unspecified unresolved
+         sources as they would always end up in the offline state */
+      if ((address->family == IPADDR_UNSPEC &&
+           (connectivity != SRC_MAYBE_ONLINE || UTI_IsIPReal(&record->remote_addr->ip_addr))) ||
           !UTI_CompareIPs(&record->remote_addr->ip_addr, address, mask)) {
         any = 1;
         if (NCR_IsSyncPeer(record->data)) {