]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: improve copying of server status
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 29 Apr 2024 09:21:45 +0000 (11:21 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 29 Apr 2024 09:21:45 +0000 (11:21 +0200)
When a server specified with the copy option responds with an
unsynchronized status (e.g. due to selection failure), reset the
source instance to immediately switch the local reference status
instead of waiting for the source to become unreachable after 8 polls.

ntp_core.c

index 149e32aff4d87ec25745f60ee6c592669d0e644e..214a989edd469340f34e1d61100eae675f025469 100644 (file)
@@ -2372,13 +2372,17 @@ process_response(NCR_Instance inst, int saved, NTP_Local_Address *local_addr,
 
     SRC_UpdateReachability(inst->source, synced_packet);
 
-    if (synced_packet) {
-      if (inst->copy && inst->remote_stratum > 0) {
-        /* Assume the reference ID and stratum of the server */
+    if (inst->copy) {
+      /* Assume the reference ID and stratum of the server */
+      if (synced_packet && inst->remote_stratum > 0) {
         inst->remote_stratum--;
         SRC_SetRefid(inst->source, ntohl(message->reference_id), &inst->remote_addr.ip_addr);
+      } else {
+        SRC_ResetInstance(inst->source);
       }
+    }
 
+    if (synced_packet) {
       SRC_UpdateStatus(inst->source, MAX(inst->remote_stratum, inst->min_stratum), pkt_leap);
 
       if (inst->delay_quant)