]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
clientlog: count authenticated NTP requests
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 20 May 2020 08:49:45 +0000 (10:49 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 May 2020 10:01:39 +0000 (12:01 +0200)
clientlog.c
clientlog.h
ntp_core.c

index 72682e1756bc6fdd5c9aa1e35efe3a4d7971876f..dbb76b9f3ad9f0053a24f4ad3209715358f33fe0 100644 (file)
@@ -127,6 +127,7 @@ static int active;
 /* Global statistics */
 static uint32_t total_hits[MAX_SERVICES];
 static uint32_t total_drops[MAX_SERVICES];
+static uint32_t total_ntp_auth_hits;
 static uint32_t total_record_drops;
 
 #define NSEC_PER_SEC 1000000000U
@@ -585,6 +586,14 @@ CLG_LimitServiceRate(CLG_Service service, int index)
 
 /* ================================================== */
 
+void
+CLG_LogAuthNtpRequest(void)
+{
+  total_ntp_auth_hits++;
+}
+
+/* ================================================== */
+
 void CLG_GetNtpTimestamps(int index, NTP_int64 **rx_ts, NTP_int64 **tx_ts)
 {
   Record *record;
index de3eb9811b8293da893ec92d3b2de505aacd79fc..6349646bb8d5bb1681da38e82da0cab821a96abc 100644 (file)
@@ -42,6 +42,7 @@ extern void CLG_Finalise(void);
 extern int CLG_GetClientIndex(IPAddr *client);
 extern int CLG_LogServiceAccess(CLG_Service service, IPAddr *client, struct timespec *now);
 extern int CLG_LimitServiceRate(CLG_Service service, int index);
+extern void CLG_LogAuthNtpRequest(void);
 extern void CLG_GetNtpTimestamps(int index, NTP_int64 **rx_ts, NTP_int64 **tx_ts);
 extern int CLG_GetNtpMinPoll(void);
 
index 8a99ceb6d87e6bfdbbff2c7ba3c30cb8c3d76a4f..4da9e956ffaa30f523756b6c97e9c06556585ab9 100644 (file)
@@ -2096,6 +2096,8 @@ NCR_ProcessRxUnknown(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_a
     /* Don't respond unless a non-zero KoD was returned */
     if (kod == 0)
       return;
+  } else if (info.auth.mode != NTP_AUTH_NONE && info.auth.mode != NTP_AUTH_MSSNTP) {
+    CLG_LogAuthNtpRequest();
   }
 
   /* If it is an NTPv4 packet with a long MAC and no extension fields,