From: Miroslav Lichvar Date: Mon, 9 Mar 2020 11:26:51 +0000 (+0100) Subject: ntp: ignore onoffline command for unresolved sources X-Git-Tag: 4.0-pre1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27b3bf48ea16e748028f6fbce3123ad2fc635358;p=thirdparty%2Fchrony.git ntp: ignore onoffline command for unresolved sources 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). --- diff --git a/ntp_sources.c b/ntp_sources.c index 995da1b9..dfdcff22 100644 --- a/ntp_sources.c +++ b/ntp_sources.c @@ -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)) {