| [chrony-dev] [RFC PATCH v1 17/17] client, cmdmon, doc/chrony.conf, doc/chronyc: Add chronyc command to query allocated clock ID |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [RFC PATCH v1 17/17] client, cmdmon, doc/chrony.conf, doc/chronyc: Add chronyc command to query allocated clock ID
- From: Christopher S M Hall <christopher.s.hall@xxxxxxxxx>
- Date: Sat, 6 Dec 2025 06:11:03 +0000
- Cc: christopher.s.hall@xxxxxxxxx, david.zage@xxxxxxxxx, yoong.siang.song@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765002158; x=1796538158; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SuFdd/aNBqSA7YArU2oWBzStNhGEn4jSPzjIYga9PMQ=; b=Rzihv6kdMSiGWPFnZaz+rI/EvFllLxWxXRvVbqRjYx36y8lhSiMB8c4c 8fNCo1s5Nn97uci+R3m5hCHcpIWx3DOZ2nCDOy/tJqtPhGSumUe9ty3Ul wdBkPucKD3g6qQVYpUZWfTqjTnU6AJ44AWdhjK2E/bXp2GgOv99rFwruu gsJ5Eu1bpQvJaYSY/2D6+4+4oIRSzqqPnOysoeYSRFleZ8jqrJN/vTyfV x7FQ08FYCT6QTI4JH/YSb1N+EDva0/z5pVEd+LJkG3G1KbUZrKs0cX/32 Cm81CZp6yYkahuBgfynwE+4r9PjAoUrPvZW0vb/rfBkG62zX3nBFjwAIs w==;
Add a command 'auxclockid' to chronyc to query the clock ID. When using a pre-allocated auxiliary clock
this returns the same information specified in the configuration file. For dynamically allocated
auxiliary clock IDs using the "auxclockid alloc" directive, the command returns the allocated clock ID.
---
candm.h | 12 ++++++++++--
client.c | 28 ++++++++++++++++++++++++++++
cmdmon.c | 20 ++++++++++++++++++++
doc/chrony.conf.adoc | 2 +-
doc/chronyc.adoc | 13 +++++++++++++
pktlength.c | 2 ++
6 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/candm.h b/candm.h
index 16038c5..6f8b205 100644
--- a/candm.h
+++ b/candm.h
@@ -111,7 +111,8 @@
#define REQ_MODIFY_SELECTOPTS 72
#define REQ_MODIFY_OFFSET 73
#define REQ_LOCAL3 74
-#define N_REQUEST_TYPES 75
+#define REQ_AUXCLOCK_ID 75
+#define N_REQUEST_TYPES 76
/* Structure used to exchange timespecs independent of time_t size */
typedef struct {
@@ -540,7 +541,8 @@ typedef struct {
#define RPY_SERVER_STATS3 24
#define RPY_SERVER_STATS4 25
#define RPY_NTP_DATA2 26
-#define N_REPLY_TYPES 27
+#define RPY_AUXCLOCK_ID 27
+#define N_REPLY_TYPES 28
/* Status codes */
#define STT_SUCCESS 0
@@ -815,6 +817,11 @@ typedef struct {
int32_t EOR;
} RPY_SelectData;
+typedef struct {
+ int32_t clock_id;
+ int32_t EOR;
+} RPY_AuxClockId;
+
typedef struct {
uint8_t version;
uint8_t pkt_type;
@@ -847,6 +854,7 @@ typedef struct {
RPY_NTPSourceName ntp_source_name;
RPY_AuthData auth_data;
RPY_SelectData select_data;
+ RPY_AuxClockId auxclock_id;
} data; /* Reply specific parameters */
} CMD_Reply;
diff --git a/client.c b/client.c
index da66ea5..f253c5e 100644
--- a/client.c
+++ b/client.c
@@ -1236,6 +1236,9 @@ give_help(void)
"rtcdata\0Print current RTC performance parameters\0"
"trimrtc\0Correct RTC relative to system clock\0"
"writertc\0Save RTC performance parameters to file\0"
+#ifdef FEAT_AUXCLOCK
+ "auxclockid\0Print dynamically allocated Clock ID\0"
+#endif
"\0\0"
"Other daemon commands:\0\0"
"cyclelogs\0Close and re-open log files\0"
@@ -3318,6 +3321,26 @@ process_cmd_keygen(char *line)
/* ================================================== */
+#ifdef FEAT_AUXCLOCK
+
+static int
+process_cmd_auxclockid()
+{
+ CMD_Request request;
+ CMD_Reply reply;
+
+ request.command = htons(REQ_AUXCLOCK_ID);
+ if(request_reply(&request, &reply, RPY_AUXCLOCK_ID, 0)) {
+ print_report("Dynamic Auxilliary Clock ID: %d\n", reply.data.auxclock_id, REPORT_END);
+ return 1;
+ }
+ return 0;
+}
+
+#endif
+
+/* ================================================== */
+
static int
process_line(char *line)
{
@@ -3354,6 +3377,11 @@ process_line(char *line)
} else if (!strcmp(command, "authdata")) {
do_normal_submit = 0;
ret = process_cmd_authdata(line);
+#ifdef FEAT_AUXCLOCK
+ } else if (!strcmp(command, "auxclockid")) {
+ do_normal_submit = 0;
+ ret = process_cmd_auxclockid(&tx_message);
+#endif
} else if (!strcmp(command, "burst")) {
do_normal_submit = process_cmd_burst(&tx_message, line);
} else if (!strcmp(command, "clients")) {
diff --git a/cmdmon.c b/cmdmon.c
index 08d1cef..0ca8ff1 100644
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1368,6 +1368,21 @@ handle_modify_offset(CMD_Request *rx_message, CMD_Reply *tx_message)
/* ================================================== */
+#ifdef FEAT_AUXCLOCK
+static void
+handle_auxclock_id(CMD_Request *rx_message, CMD_Reply *tx_message)
+{
+ if (!CNF_GetAuxClockDynamic()) {
+ tx_message->status = htons(STT_NOTENABLED);
+ } else {
+ tx_message->reply = htons(RPY_AUXCLOCK_ID);
+ tx_message->data.auxclock_id.clock_id = *CNF_GetAuxClockId();
+ }
+}
+#endif
+
+/* ================================================== */
+
static int
handle_readwrite_commands(int command, CMD_Request *request, CMD_Reply *reply)
{
@@ -1545,6 +1560,11 @@ handle_readonly_commands(int command, int full_access, CMD_Request *request, CMD
case REQ_AUTH_DATA:
handle_auth_data(request, reply);
break;
+#ifdef FEAT_AUXCLOCK
+ case REQ_AUXCLOCK_ID:
+ handle_auxclock_id(request, reply);
+ break;
+#endif
case REQ_CLIENT_ACCESSES_BY_INDEX3:
handle_client_accesses_by_index(request, reply);
break;
diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc
index 63acaf2..6ac9d3b 100644
--- a/doc/chrony.conf.adoc
+++ b/doc/chrony.conf.adoc
@@ -1591,7 +1591,7 @@ at startup and frees that clock ID on exit
auxclockid alloc
----
The dynamically allocated clock ID, is found in the file specified by _auxclockidfile_
-directive (See _auxclockidfile_)
+directive (See _auxclockidfile_) and can be read using chronyc with the _auxclockid_ command
[[nooffsetsanitycheck]]
*nooffsetsanitycheck* ::
diff --git a/doc/chronyc.adoc b/doc/chronyc.adoc
index b7f30c6..3801d65 100644
--- a/doc/chronyc.adoc
+++ b/doc/chronyc.adoc
@@ -314,6 +314,19 @@ which will wait up to about 10 minutes (60 times 10 seconds) for *chronyd* to
synchronise to a source and the remaining correction to be less than 10
milliseconds.
+[[auxclockid]]*auxclockid*::
+Retrieve the Clock ID of the allocated auxiliary
++
+If chrony is configured to allocate an auxilliary clock, returns the Clock ID
+that was allocated.
++
+An example of chronyc output querying Auxiliary Clock ID is:
++
+----
+chronyc> auxclockid
+Dynamic Auxilliary Clock ID: 16
+----
+
=== Time sources
[[sources]]*sources* [*-a*] [*-v*]::
diff --git a/pktlength.c b/pktlength.c
index d9348ef..5d75a69 100644
--- a/pktlength.c
+++ b/pktlength.c
@@ -132,6 +132,7 @@ static const struct request_length request_lengths[] = {
REQ_LENGTH_ENTRY(modify_select_opts, null), /* MODIFY_SELECTOPTS */
REQ_LENGTH_ENTRY(modify_offset, null), /* MODIFY_OFFSET */
REQ_LENGTH_ENTRY(local, null), /* LOCAL3 */
+ REQ_LENGTH_ENTRY(null, auxclock_id), /* Auxilliary Clock ID */
};
static const uint16_t reply_lengths[] = {
@@ -162,6 +163,7 @@ static const uint16_t reply_lengths[] = {
0, /* SERVER_STATS3 - not supported */
RPY_LENGTH_ENTRY(server_stats), /* SERVER_STATS4 */
RPY_LENGTH_ENTRY(ntp_data), /* NTP_DATA2 */
+ RPY_LENGTH_ENTRY(auxclock_id), /* Auxiliary Clock ID */
};
/* ================================================== */
--
2.34.1
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.