]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: add timestamp counters to ntpdata report
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 6 Feb 2024 13:56:30 +0000 (14:56 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 7 Feb 2024 09:23:40 +0000 (10:23 +0100)
candm.h
client.c
cmdmon.c
doc/chronyc.adoc
pktlength.c
test/simulation/110-chronyc
test/system/007-cmdmon

diff --git a/candm.h b/candm.h
index 5fe12222bf98c859238656c97b99d24006ab7de6..65daedfcfce86446f1581328b97413c3569efc3a 100644 (file)
--- a/candm.h
+++ b/candm.h
@@ -540,7 +540,8 @@ typedef struct {
 #define RPY_SELECT_DATA 23
 #define RPY_SERVER_STATS3 24
 #define RPY_SERVER_STATS4 25
-#define N_REPLY_TYPES 26
+#define RPY_NTP_DATA2 26
+#define N_REPLY_TYPES 27
 
 /* Status codes */
 #define STT_SUCCESS 0
@@ -763,7 +764,11 @@ typedef struct {
   uint32_t total_rx_count;
   uint32_t total_valid_count;
   uint32_t total_good_count;
-  uint32_t reserved[3];
+  uint32_t total_kernel_tx_ts;
+  uint32_t total_kernel_rx_ts;
+  uint32_t total_hw_tx_ts;
+  uint32_t total_hw_rx_ts;
+  uint32_t reserved[4];
   int32_t EOR;
 } RPY_NTPData;
 
index d5e3be71bac1f22ded55a6df6aae84311584f1d5..5ead2b0aa1528c255dd6691782540ba97f80e000 100644 (file)
--- a/client.c
+++ b/client.c
@@ -2331,7 +2331,7 @@ process_cmd_ntpdata(char *line)
 
     request.command = htons(REQ_NTP_DATA);
     UTI_IPHostToNetwork(&remote_addr, &request.data.ntp_data.ip_addr);
-    if (!request_reply(&request, &reply, RPY_NTP_DATA, 0))
+    if (!request_reply(&request, &reply, RPY_NTP_DATA2, 0))
       return 0;
 
     UTI_IPNetworkToHost(&reply.data.ntp_data.remote_addr, &remote_addr);
@@ -2367,7 +2367,11 @@ process_cmd_ntpdata(char *line)
                  "Total TX        : %U\n"
                  "Total RX        : %U\n"
                  "Total valid RX  : %U\n"
-                 "Total good RX   : %U\n",
+                 "Total good RX   : %U\n"
+                 "Total kernel TX : %U\n"
+                 "Total kernel RX : %U\n"
+                 "Total HW TX     : %U\n"
+                 "Total HW RX     : %U\n",
                  UTI_IPToString(&remote_addr), UTI_IPToRefid(&remote_addr),
                  ntohs(reply.data.ntp_data.remote_port),
                  UTI_IPToString(&local_addr), UTI_IPToRefid(&local_addr),
@@ -2395,6 +2399,10 @@ process_cmd_ntpdata(char *line)
                  ntohl(reply.data.ntp_data.total_rx_count),
                  ntohl(reply.data.ntp_data.total_valid_count),
                  ntohl(reply.data.ntp_data.total_good_count),
+                 ntohl(reply.data.ntp_data.total_kernel_tx_ts),
+                 ntohl(reply.data.ntp_data.total_kernel_rx_ts),
+                 ntohl(reply.data.ntp_data.total_hw_tx_ts),
+                 ntohl(reply.data.ntp_data.total_hw_rx_ts),
                  REPORT_END);
   }
 
index c5b00a4aeb4af1f7db4481ab79a564f864e0e197..0a0193b1d79ef5828c44b0597fd55a836fb51534 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1230,7 +1230,7 @@ handle_ntp_data(CMD_Request *rx_message, CMD_Reply *tx_message)
     return;
   }
 
-  tx_message->reply = htons(RPY_NTP_DATA);
+  tx_message->reply = htons(RPY_NTP_DATA2);
   UTI_IPHostToNetwork(&report.remote_addr, &tx_message->data.ntp_data.remote_addr);
   UTI_IPHostToNetwork(&report.local_addr, &tx_message->data.ntp_data.local_addr);
   tx_message->data.ntp_data.remote_port = htons(report.remote_port);
@@ -1258,6 +1258,10 @@ handle_ntp_data(CMD_Request *rx_message, CMD_Reply *tx_message)
   tx_message->data.ntp_data.total_rx_count = htonl(report.total_rx_count);
   tx_message->data.ntp_data.total_valid_count = htonl(report.total_valid_count);
   tx_message->data.ntp_data.total_good_count = htonl(report.total_good_count);
+  tx_message->data.ntp_data.total_kernel_tx_ts = htonl(report.total_kernel_tx_ts);
+  tx_message->data.ntp_data.total_kernel_rx_ts = htonl(report.total_kernel_rx_ts);
+  tx_message->data.ntp_data.total_hw_tx_ts = htonl(report.total_hw_tx_ts);
+  tx_message->data.ntp_data.total_hw_rx_ts = htonl(report.total_hw_rx_ts);
   memset(tx_message->data.ntp_data.reserved, 0xff, sizeof (tx_message->data.ntp_data.reserved));
 }
 
index 96a05517a2fcb0f9678ae4e7f3f0b5aae0af07e5..8e0d426e56eb62d2a7156321d9f8eaee1eafc3fe 100644 (file)
@@ -689,6 +689,10 @@ Total TX        : 24
 Total RX        : 24
 Total valid RX  : 24
 Total good RX   : 22
+Total kernel TX : 24
+Total kernel RX : 24
+Total HW TX     : 0
+Total HW RX     : 0
 ----
 +
 The fields are explained as follows:
@@ -746,6 +750,18 @@ The number of packets which passed the first two groups of NTP tests.
 *Total good RX*:::
 The number of packets which passed all three groups of NTP tests, i.e. the NTP
 measurement was accepted.
+*Total kernel TX*:::
+The number of packets sent to the source for which a timestamp was captured by
+the kernel.
+*Total kernel RX*:::
+The number of packets received from the source for which a timestamp was
+captured by the kernel.
+*Total HW TX*:::
+The number of packets sent to the source for which a timestamp was captured by
+the NIC.
+*Total HW RX*:::
+The number of packets received from the source for which a timestamp was
+captured by the NIC.
 
 [[add_peer]]*add peer* _name_ [_option_]...::
 The *add peer* command allows a new NTP peer to be added whilst
index d7ed2723ed3fa4ee2b62015c54ba3cbef5160ffa..3e0b319d209ce7498a8c2c71a07cff6d5f5e285d 100644 (file)
@@ -149,7 +149,7 @@ static const uint16_t reply_lengths[] = {
   RPY_LENGTH_ENTRY(smoothing),                  /* SMOOTHING */
   0,                                            /* SERVER_STATS - not supported */
   0,                                            /* CLIENT_ACCESSES_BY_INDEX2 - not supported */
-  RPY_LENGTH_ENTRY(ntp_data),                   /* NTP_DATA */
+  0,                                            /* NTP_DATA - not supported */
   RPY_LENGTH_ENTRY(manual_timestamp),           /* MANUAL_TIMESTAMP2 */
   RPY_LENGTH_ENTRY(manual_list),                /* MANUAL_LIST2 */
   RPY_LENGTH_ENTRY(ntp_source_name),            /* NTP_SOURCE_NAME */
@@ -159,6 +159,7 @@ static const uint16_t reply_lengths[] = {
   RPY_LENGTH_ENTRY(select_data),                /* SELECT_DATA */
   0,                                            /* SERVER_STATS3 - not supported */
   RPY_LENGTH_ENTRY(server_stats),               /* SERVER_STATS4 */
+  RPY_LENGTH_ENTRY(ntp_data),                   /* NTP_DATA2 */
 };
 
 /* ================================================== */
index 3cd17883b45dd5fe1a3f642e5b93d54eb73bf3cb..a261e7a0a9a18001c3fe4d40921f00dab7541db3 100755 (executable)
@@ -247,6 +247,10 @@ Total TX        : 1
 Total RX        : 1
 Total valid RX  : 1
 Total good RX   : 0
+Total kernel TX : [01]
+Total kernel RX : 1
+Total HW TX     : 0
+Total HW RX     : 0
 S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap
 =======================================================================
 M node1\.net1\.clk            N ----- -----    0   1\.0    \+0ns    \+0ns  N
index f9541d30fea0ec972a2176404532475829c1dc21..859950324e930a7fc44c17edb268a605fdd17474 100755 (executable)
@@ -97,7 +97,11 @@ RX timestamping : (Daemon|Kernel)
 Total TX        : [0-9]+
 Total RX        : [0-9]+
 Total valid RX  : [0-9]+
-Total good RX   : [0-9]+$" || test_fail
+Total good RX   : [0-9]+
+Total kernel TX : [0-9]+
+Total kernel RX : [0-9]+
+Total HW TX     : 0
+Total HW RX     : 0$" || test_fail
 
 run_chronyc "selectdata" || test_fail
 check_chronyc_output "^S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap