From: Miroslav Lichvar Date: Thu, 26 Jan 2023 15:21:11 +0000 (+0100) Subject: sources: warn about detected falsetickers X-Git-Tag: 4.4-pre1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b3d4dfe76679a01a920d7b45efa8b9d201fd986;p=thirdparty%2Fchrony.git sources: warn about detected falsetickers 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. --- diff --git a/sources.c b/sources.c index 66c73ad4..730ac55c 100644 --- 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;