]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Add maxdelaydevratio command
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 3 Dec 2010 17:41:35 +0000 (18:41 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 7 Dec 2010 15:47:57 +0000 (16:47 +0100)
candm.h
chrony.texi
client.c
cmdmon.c
ntp_core.c
ntp_core.h
ntp_sources.c
ntp_sources.h
pktlength.c

diff --git a/candm.h b/candm.h
index 25e17378ffa48c9b62038c9cdf5a9f7e0ba2dd88..ac8e4cb5e17493d66983ac8305e418c6e2fa67a4 100644 (file)
--- a/candm.h
+++ b/candm.h
@@ -88,7 +88,8 @@
 #define REQ_ACTIVITY 44
 #define REQ_MODIFY_MINSTRATUM 45
 #define REQ_MODIFY_POLLTARGET 46
-#define N_REQUEST_TYPES 47
+#define REQ_MODIFY_MAXDELAYDEVRATIO 47
+#define N_REQUEST_TYPES 48
 
 /* Special utoken value used to log on with first exchange being the
    password.  (This time value has long since gone by) */
@@ -164,6 +165,12 @@ typedef struct {
   int32_t EOR;
 } REQ_Modify_Maxdelayratio;
 
+typedef struct {
+  IPAddr address;
+  Float new_max_delay_dev_ratio;
+  int32_t EOR;
+} REQ_Modify_Maxdelaydevratio;
+
 typedef struct {
   IPAddr address;
   int32_t new_min_stratum;
@@ -386,6 +393,7 @@ typedef struct {
     REQ_Dump dump;
     REQ_Modify_Maxdelay modify_maxdelay;
     REQ_Modify_Maxdelayratio modify_maxdelayratio;
+    REQ_Modify_Maxdelaydevratio modify_maxdelaydevratio;
     REQ_Modify_Minstratum modify_minstratum;
     REQ_Modify_Polltarget modify_polltarget;
     REQ_Modify_Maxupdateskew modify_maxupdateskew;
index d25421f56ebdaa9cddf2454e8e079842c1a95480..6b4c4224d03111c83ba6a74991267f27befa0b75 100644 (file)
@@ -2874,6 +2874,7 @@ interface.
 * manual command::              Enable/disable/configure options for settime
 * maxdelay command::            Set max measurement delay for a source
 * maxdelayratio command::       Set max measurement delay for a source as ratio
+* maxdelaydevratio command::    Set max measurement delay for a source as ratio to deviation
 * maxpoll command::             Set maximum polling interval for a source
 * maxupdateskew command::       Set safety threshold for clock gain/loss rate
 * minpoll command::             Set minimum polling interval for a source
@@ -3438,6 +3439,22 @@ address @code{2001:db8::1} to be double the retained minimum.
 As for @code{maxdelay}, any measurement whose network delay is too large
 will be discarded.
 @c }}}
+@c {{{ maxdelaydevratio
+@node maxdelaydevratio command
+@subsubsection maxdelaydevratio
+This allows the @code{maxdelaydevratio} option for one of the sources to be
+modified, in the same way as specifying the @code{maxdelaydevratio} option
+for the @code{server} directive in the configuration file (@pxref{server
+directive}).
+
+The following examples illustrate the syntax
+
+@example
+maxdelaydevratio foo.bar.com 0.1
+maxdelaydevratio 1.2.3.4 1.0
+maxdelaydevratio 2001:db8::1 100.0
+@end example
+@c }}}
 @c {{{ maxpoll
 @node maxpoll command
 @subsubsection maxpoll
index 67456e43a033566fe80e10143aea281e0b37da7a..c5bc047cab08545a5f5a3b23d7ea029d3b351655 100644 (file)
--- a/client.c
+++ b/client.c
@@ -436,6 +436,28 @@ process_cmd_maxdelay(CMD_Request *msg, char *line)
 
 /* ================================================== */
 
+static int
+process_cmd_maxdelaydevratio(CMD_Request *msg, char *line)
+{
+  IPAddr address;
+  double max_delay_dev_ratio;
+  int ok;
+  
+  if (read_address_double(line, &address, &max_delay_dev_ratio)) {
+    UTI_IPHostToNetwork(&address, &msg->data.modify_maxdelaydevratio.address);
+    msg->data.modify_maxdelayratio.new_max_delay_ratio = UTI_FloatHostToNetwork(max_delay_dev_ratio);
+    msg->command = htons(REQ_MODIFY_MAXDELAYDEVRATIO);
+    ok = 1;
+  } else {
+    ok = 0;
+  }
+
+  return ok;
+
+}
+
+/* ================================================== */
+
 static int
 process_cmd_maxdelayratio(CMD_Request *msg, char *line)
 {
@@ -2439,6 +2461,8 @@ process_line(char *line, int *quit)
     do_normal_submit = process_cmd_maxpoll(&tx_message, p+7);
   } else if (!strncmp(p, "dump", 4)) {
     process_cmd_dump(&tx_message, p+4);
+  } else if (!strncmp(p, "maxdelaydevratio", 16)) {
+    do_normal_submit = process_cmd_maxdelaydevratio(&tx_message, p+16);
   } else if (!strncmp(p, "maxdelayratio", 13)) {
     do_normal_submit = process_cmd_maxdelayratio(&tx_message, p+13);
   } else if (!strncmp(p, "maxdelay", 8)) {
index 3d5df7404c2966cd7d8f9eefda507da4fbed5c1d..fa77c8a7b2248c26efdfd64ef06c5a5b70831c40 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -160,7 +160,8 @@ static int permissions[] = {
   PERMIT_AUTH, /* MAKESTEP */
   PERMIT_OPEN, /* ACTIVITY */
   PERMIT_AUTH, /* MODIFY_MINSTRATUM */
-  PERMIT_AUTH  /* MODIFY_POLLTARGET */
+  PERMIT_AUTH, /* MODIFY_POLLTARGET */
+  PERMIT_AUTH  /* MODIFY_MAXDELAYDEVRATIO */
 };
 
 /* ================================================== */
@@ -904,6 +905,23 @@ handle_modify_maxdelayratio(CMD_Request *rx_message, CMD_Reply *tx_message)
 
 /* ================================================== */
 
+static void
+handle_modify_maxdelaydevratio(CMD_Request *rx_message, CMD_Reply *tx_message)
+{
+  int status;
+  IPAddr address;
+  UTI_IPNetworkToHost(&rx_message->data.modify_maxdelaydevratio.address, &address);
+  status = NSR_ModifyMaxdelaydevratio(&address,
+                                   UTI_FloatNetworkToHost(rx_message->data.modify_maxdelaydevratio.new_max_delay_dev_ratio));
+  if (status) {
+    tx_message->status = htons(STT_SUCCESS);
+  } else {
+    tx_message->status = htons(STT_NOSUCHSOURCE);
+  }
+}
+
+/* ================================================== */
+
 static void
 handle_modify_minstratum(CMD_Request *rx_message, CMD_Reply *tx_message)
 {
@@ -2052,6 +2070,10 @@ read_from_cmd_socket(void *anything)
           handle_modify_maxdelayratio(&rx_message, &tx_message);
           break;
 
+        case REQ_MODIFY_MAXDELAYDEVRATIO:
+          handle_modify_maxdelaydevratio(&rx_message, &tx_message);
+          break;
+
         case REQ_MODIFY_MAXUPDATESKEW:
           handle_modify_maxupdateskew(&rx_message, &tx_message);
           break;
index 42115942c020c05e8215b7c0366908e6a4540232..8bfd7b4e450e5d93ad359e85cb112e8cddc2a717 100644 (file)
@@ -1751,6 +1751,16 @@ NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_ratio)
 
 /* ================================================== */
 
+void
+NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_dev_ratio)
+{
+  inst->max_delay_dev_ratio = new_max_delay_dev_ratio;
+  LOG(LOGS_INFO, LOGF_NtpCore, "Source %s new max delay dev ratio %f",
+      UTI_IPToString(&inst->remote_addr.ip_addr), new_max_delay_dev_ratio);
+}
+
+/* ================================================== */
+
 void
 NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum)
 {
index 76449c68699ea9b3e36264f8607ceb5269cbfa5b..c5eede72ea8858df4f869d1b83ad162092eb550b 100644 (file)
@@ -91,6 +91,8 @@ extern void NCR_ModifyMaxdelay(NCR_Instance inst, double new_max_delay);
 
 extern void NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_ratio);
 
+extern void NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_dev_ratio);
+
 extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
 
 extern void NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target);
index 2f5bb8fc4055354f1a4137899e449604fd3c7356..dd9a75df911dfb19192e148e0a6b1d7afa0d9493 100644 (file)
@@ -555,6 +555,25 @@ NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio)
 
 /* ================================================== */
 
+int
+NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_dev_ratio)
+{
+  int slot, found;
+  NTP_Remote_Address addr;
+  addr.ip_addr = *address;
+  addr.port = 0;
+
+  find_slot(&addr, &slot, &found);
+  if (found == 0) {
+    return 0;
+  } else {
+    NCR_ModifyMaxdelaydevratio(records[slot].data, new_max_delay_dev_ratio);
+    return 1;
+  }
+}
+
+/* ================================================== */
+
 int
 NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum)
 {
index de5b3fb6defddd98918a174e7d7d93b365dabadf..4a31a58dc3ab537dfbcf250a451a958c5e4dceb4 100644 (file)
@@ -91,6 +91,8 @@ extern int NSR_ModifyMaxdelay(IPAddr *address, double new_max_delay);
 
 extern int NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio);
 
+extern int NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_ratio);
+
 extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
 
 extern int NSR_ModifyPolltarget(IPAddr *address, int new_poll_target);
index 8b735af06971c1fdc8e0914e8d2fddb124e1b646..dc1d059ed451548635eb041a4e3e1169533be8d4 100644 (file)
@@ -65,6 +65,8 @@ PKL_CommandLength(CMD_Request *r)
         return offsetof(CMD_Request, data.modify_maxdelay.EOR);
       case REQ_MODIFY_MAXDELAYRATIO:
         return offsetof(CMD_Request, data.modify_maxdelayratio.EOR);
+      case REQ_MODIFY_MAXDELAYDEVRATIO:
+        return offsetof(CMD_Request, data.modify_maxdelaydevratio.EOR);
       case REQ_MODIFY_MAXUPDATESKEW:
         return offsetof(CMD_Request, data.modify_maxupdateskew.EOR);
       case REQ_LOGON :