From 93008544394435d30decf7942ccdff966544f660 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 4 Dec 2019 15:26:39 +0100 Subject: [PATCH] cmdmon: add support for adding pool sources Specify a new type for pool sources and extend the syntax of the chronyc "add" command to add a pool. --- candm.h | 1 + client.c | 3 +++ cmdmon.c | 10 ++++++++-- doc/chronyc.adoc | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/candm.h b/candm.h index 6846fd1..8fe2255 100644 --- a/candm.h +++ b/candm.h @@ -249,6 +249,7 @@ typedef struct { /* Source types in NTP source requests */ #define REQ_ADDSRC_SERVER 1 #define REQ_ADDSRC_PEER 2 +#define REQ_ADDSRC_POOL 3 /* Flags used in NTP source requests */ #define REQ_ADDSRC_ONLINE 0x1 diff --git a/client.c b/client.c index eb1acc0..4d38691 100644 --- a/client.c +++ b/client.c @@ -1069,6 +1069,8 @@ process_cmd_add_source(CMD_Request *msg, char *line) type = REQ_ADDSRC_SERVER; } else if (!strcmp(word, "peer")) { type = REQ_ADDSRC_PEER; + } else if (!strcmp(word, "pool")) { + type = REQ_ADDSRC_POOL; } else { LOG(LOGS_ERR, "Invalid syntax for add command"); return 0; @@ -1193,6 +1195,7 @@ give_help(void) "activity\0Check how many NTP sources are online/offline\0" "ntpdata [
]\0Display information about last valid measurement\0" "add server [options]\0Add new NTP server\0" + "add pool [options]\0Add new pool of NTP servers\0" "add peer [options]\0Add new NTP peer\0" "delete
\0Remove server or peer\0" "burst / [/
]\0Start rapid set of measurements\0" diff --git a/cmdmon.c b/cmdmon.c index 4fa9b0c..70fa2c9 100644 --- a/cmdmon.c +++ b/cmdmon.c @@ -682,14 +682,20 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message) SourceParameters params; NSR_Status status; char *name; - int port; + int pool, port; switch (ntohl(rx_message->data.ntp_source.type)) { case REQ_ADDSRC_SERVER: type = NTP_SERVER; + pool = 0; break; case REQ_ADDSRC_PEER: type = NTP_PEER; + pool = 0; + break; + case REQ_ADDSRC_POOL: + type = NTP_SERVER; + pool = 1; break; default: tx_message->status = htons(STT_INVALID); @@ -737,7 +743,7 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message) (ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_TRUST ? SRC_SELECT_TRUST : 0) | (ntohl(rx_message->data.ntp_source.flags) & REQ_ADDSRC_REQUIRE ? SRC_SELECT_REQUIRE : 0); - status = NSR_AddSourceByName(name, port, 0, type, ¶ms); + status = NSR_AddSourceByName(name, port, pool, type, ¶ms); switch (status) { case NSR_Success: break; diff --git a/doc/chronyc.adoc b/doc/chronyc.adoc index 4dd2d6d..4905618 100644 --- a/doc/chronyc.adoc +++ b/doc/chronyc.adoc @@ -540,6 +540,20 @@ An example of using this command is shown below. add peer foo.example.net minpoll 6 maxpoll 10 key 25 ---- +[[add_pool]]*add pool* _name_ [_option_]...:: +The *add pool* command allows a pool of NTP servers to be added whilst +*chronyd* is running. ++ +Following the words *add pool*, the syntax of the following parameters and +options is identical to that for the <> +directive in the configuration file. ++ +An example of using this command is shown below: ++ +---- +add pool foo.example.net maxsources 3 iburst +---- + [[add_server]]*add server* _name_ [_option_]...:: The *add server* command allows a new NTP server to be added whilst *chronyd* is running.