]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: add support for adding pool sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 4 Dec 2019 14:26:39 +0000 (15:26 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Dec 2019 13:44:03 +0000 (14:44 +0100)
Specify a new type for pool sources and extend the syntax of the chronyc
"add" command to add a pool.

candm.h
client.c
cmdmon.c
doc/chronyc.adoc

diff --git a/candm.h b/candm.h
index 6846fd1b52ae10d7f22a93d5d38c68022c2de3a9..8fe22557b9a4fff20863774fee299d88275a923d 100644 (file)
--- 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
index eb1acc01af4b94ddd191c95b8785f62a3aca5423..4d38691f7186989a6ba95e5662f8cc2dd27af2e4 100644 (file)
--- 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 [<address>]\0Display information about last valid measurement\0"
     "add server <name> [options]\0Add new NTP server\0"
+    "add pool <name> [options]\0Add new pool of NTP servers\0"
     "add peer <name> [options]\0Add new NTP peer\0"
     "delete <address>\0Remove server or peer\0"
     "burst <n-good>/<n-max> [<mask>/<address>]\0Start rapid set of measurements\0"
index 4fa9b0c866af64da53004481418e7d96ff59a6b6..70fa2c9da3514b4ee953ab1385f3eb4c2dae8484 100644 (file)
--- 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, &params);
+  status = NSR_AddSourceByName(name, port, pool, type, &params);
   switch (status) {
     case NSR_Success:
       break;
index 4dd2d6de2593632157d345c44c77cfdbc9d4ffff..49056182883f854685d74427e060a757e044fd85 100644 (file)
@@ -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 <<chrony.conf.adoc#pool,*pool*>>
+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.