]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: add per-source counters of kernel and hardware timestamps
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 6 Feb 2024 13:27:14 +0000 (14:27 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 7 Feb 2024 09:23:40 +0000 (10:23 +0100)
ntp_core.c
reports.h

index 35801744a1e543fd6baf7011931c29e61935be10..44682ec4a75ff76842e9b67d52831ad87543612f 100644 (file)
@@ -221,7 +221,7 @@ struct NCR_Instance_Record {
   int burst_good_samples_to_go;
   int burst_total_samples_to_go;
 
-  /* Report from last valid response */
+  /* Report from last valid response and packet/timestamp statistics */
   RPT_NTPReport report;
 };
 
@@ -2530,6 +2530,10 @@ NCR_ProcessRxKnown(NCR_Instance inst, NTP_Local_Address *local_addr,
   NTP_PacketInfo info;
 
   inst->report.total_rx_count++;
+  if (rx_ts->source == NTP_TS_KERNEL)
+    inst->report.total_kernel_rx_ts++;
+  else if (rx_ts->source == NTP_TS_HARDWARE)
+    inst->report.total_hw_rx_ts++;
 
   if (!parse_packet(message, length, &info))
     return 0;
@@ -2812,8 +2816,11 @@ NCR_ProcessTxKnown(NCR_Instance inst, NTP_Local_Address *local_addr,
                       message);
 
   if (tx_ts->source == NTP_TS_HARDWARE) {
+    inst->report.total_hw_tx_ts++;
     if (has_saved_response(inst))
       process_saved_response(inst);
+  } else if (tx_ts->source == NTP_TS_KERNEL) {
+    inst->report.total_kernel_tx_ts++;
   }
 }
 
index 0150fc67cf822a5476b0112d0016a53bbf7e64a0..0f4751de4187367f188f3c2a64bf5b2d39907b51 100644 (file)
--- a/reports.h
+++ b/reports.h
@@ -181,6 +181,10 @@ typedef struct {
   uint32_t total_rx_count;
   uint32_t total_valid_count;
   uint32_t total_good_count;
+  uint32_t total_kernel_tx_ts;
+  uint32_t total_kernel_rx_ts;
+  uint32_t total_hw_tx_ts;
+  uint32_t total_hw_rx_ts;
 } RPT_NTPReport;
 
 typedef struct {