]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: warn about detected falsetickers
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 26 Jan 2023 15:21:11 +0000 (16:21 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 26 Jan 2023 16:03:35 +0000 (17:03 +0100)
Log a warning message for each detected falseticker, but only once
between changes in the selection of the best source. Don't print all
sources when no majority is reached as that case has its own warning
message.

sources.c

index 66c73ad45ab3fa51b1de28e7478a05cac26f7d72..730ac55c96a032a74e64d7674f572f809e62c066 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -140,6 +140,10 @@ struct SRC_Instance_Record {
 
   /* Flag indicating the source has a leap second vote */
   int leap_vote;
+
+  /* Flag indicating the source was already reported as
+     a falseticker since the last selection change */
+  int reported_falseticker;
 };
 
 /* ================================================== */
@@ -334,6 +338,7 @@ SRC_ResetInstance(SRC_Instance instance)
   instance->stratum = 0;
   instance->leap = LEAP_Unsynchronised;
   instance->leap_vote = 0;
+  instance->reported_falseticker = 0;
 
   memset(&instance->sel_info, 0, sizeof (instance->sel_info));
 
@@ -1136,6 +1141,10 @@ SRC_SelectSource(SRC_Instance updated_inst)
         sel_req_source = 0;
     } else {
       mark_source(sources[i], SRC_FALSETICKER);
+      if (!sources[i]->reported_falseticker) {
+        log_selection_source(LOGS_WARN, "Detected falseticker %s", sources[i]);
+        sources[i]->reported_falseticker = 1;
+      }
     }
   }
 
@@ -1264,6 +1273,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
     for (i = 0; i < n_sources; i++) {
       sources[i]->sel_score = 1.0;
       sources[i]->distant = 0;
+      sources[i]->reported_falseticker = 0;
     }
 
     reported_no_majority = 0;