[Git][NTPsec/ntpsec][master] Add "recent" parameter to Mode 6 for volume control on MRU list requests.
Eric S. Raymond
gitlab at mg.gitlab.com
Thu Dec 15 13:34:37 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
bbf19159 by Eric S. Raymond at 2016-12-15T08:27:55-05:00
Add "recent" parameter to Mode 6 for volume control on MRU list requests.
- - - - -
5 changed files:
- docs/mode6.txt
- ntpclients/ntpmon
- ntpd/ntp_control.c
- ntpd/ntp_monitor.c
- pylib/packet.py
Changes:
=====================================
docs/mode6.txt
=====================================
--- a/docs/mode6.txt
+++ b/docs/mode6.txt
@@ -295,6 +295,13 @@ laddr:: Return entries associated with the server's IP
address given. No port specification is needed,
and any supplied is ignored.
+recent:: Set the reporting start point to retrieve roughly
+ a specified number of most recent entries
+ 'Roughly' because the logic cannot anticipate
+ update volume. Use this to volume-limit the
+ response when you are monitoring something like
+ a pool server with a very long MRU list.
+
resall:: 0x-prefixed hex restrict bits, which must all be
lit for an MRU entry to be included.
Has precedence over any resany=.
@@ -495,6 +502,11 @@ The cryptographic hash is normally 16 octets of MD5 hash, but if ntpd
is built with OpenSSL support it is possible to use and generate
20-octet-long SHA1 keys as well.
+== Compatibility Notes ==
+
+The "recent" parameter of CTL_OP_READ_MRU is not supported in versions
+prior to NTPsec 0.9.6.
+
'''''
include::includes/footer.txt[]
=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -160,7 +160,8 @@ if __name__ == '__main__':
variables, peer.associd))
# Now the MRU report
- span = session.mrulist()
+ limit = stdscr.getmaxyx()[0] - len(peers)
+ span = session.mrulist(recent=limit)
mru_report.now = time.time()
# The status line
=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -3212,6 +3212,12 @@ send_mru_entry(
* laddr= Return entries associated with the server's IP
* address given. No port specification is needed,
* and any supplied is ignored.
+ * recent= Set the reporting start point to retrieve roughly
+ * a specified number of most recent entries
+ * 'Roughly' because the logic cannot anticipate
+ * update volume. Use this to volume-limit the
+ * response when you are monitoring something like
+ * a pool server with a very long MRU list.
* resall= 0x-prefixed hex restrict bits which must all be
* lit for an MRU entry to be included.
* Has precedence over any resany=.
@@ -3290,6 +3296,7 @@ static void read_mru_list(
static const char resany_text[] = "resany";
static const char maxlstint_text[] = "maxlstint";
static const char laddr_text[] = "laddr";
+ static const char recent_text[] = "recent";
static const char resaxx_fmt[] = "0x%hx";
u_int limit;
@@ -3298,9 +3305,10 @@ static void read_mru_list(
u_short resany;
int mincount;
u_int maxlstint;
- sockaddr_u laddr;
+ sockaddr_u laddr; u_int recent;
endpt * lcladr;
u_int count;
+ static u_int countdown;
u_int ui;
u_int uf;
l_fp last[16];
@@ -3340,6 +3348,7 @@ static void read_mru_list(
set_var(&in_parms, resany_text, sizeof(resany_text), 0);
set_var(&in_parms, maxlstint_text, sizeof(maxlstint_text), 0);
set_var(&in_parms, laddr_text, sizeof(laddr_text), 0);
+ set_var(&in_parms, recent_text, sizeof(recent_text), 0);
for (i = 0; i < COUNTOF(last); i++) {
snprintf(buf, sizeof(buf), last_fmt, (int)i);
set_var(&in_parms, buf, strlen(buf) + 1, 0);
@@ -3355,6 +3364,7 @@ static void read_mru_list(
resall = 0;
resany = 0;
maxlstint = 0;
+ recent = 0;
lcladr = NULL;
priors = 0;
ZERO(last);
@@ -3397,6 +3407,9 @@ static void read_mru_list(
if (!decodenetnum(val, &laddr))
goto blooper;
lcladr = getinterface(&laddr, 0);
+ } else if (!strcmp(recent_text, v->text)) {
+ if (1 != sscanf(val, "%u", &recent))
+ goto blooper;
} else if (1 == sscanf(v->text, last_fmt, &si) &&
(size_t)si < COUNTOF(last)) {
if (2 != sscanf(val, "0x%08x.%08x", &ui, &uf))
@@ -3490,6 +3503,7 @@ static void read_mru_list(
mon = PREV_DLIST(mon_mru_list, mon, mru);
} else { /* start with the oldest */
mon = TAIL_DLIST(mon_mru_list, mru);
+ countdown = mru_entries;
}
/*
@@ -3514,7 +3528,8 @@ static void read_mru_list(
continue;
if (lcladr != NULL && mon->lcladr != lcladr)
continue;
-
+ if (recent != 0 && countdown-- > recent)
+ continue;
send_mru_entry(mon, count);
#ifdef USE_RANDOMIZE_RESPONSES
if (!count)
=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -52,6 +52,7 @@ uint8_t mon_hash_bits;
*/
mon_entry ** mon_hash; /* MRU hash table */
mon_entry mon_mru_list; /* mru listhead */
+u_int mru_entries; /* mru list count */
/*
* List of free structures structures, and counters of in-use and total
@@ -59,7 +60,6 @@ mon_entry mon_mru_list; /* mru listhead */
*/
static mon_entry *mon_free; /* free list or null if none */
u_int mru_alloc; /* mru list + free list count */
- u_int mru_entries; /* mru list count */
u_int mru_peakentries; /* highest mru_entries seen */
u_int mru_initalloc = INIT_MONLIST;/* entries to preallocate */
u_int mru_incalloc = INC_MONLIST;/* allocation batch factor */
=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1189,7 +1189,7 @@ class ControlSession:
raise ControlException(SERR_BADNONCE)
return polystr(self.response.strip())
- def mrulist(self, variables=None, rawhook=None):
+ def mrulist(self, variables=None, rawhook=None, recent=None):
"Retrieve MRU list data"
nonce_uses = 0
restarted_count = 0
@@ -1222,7 +1222,7 @@ class ControlSession:
raise ControlException(SERR_BADSORT % sortkey)
for k in list(variables.keys()):
if k in ("mincount", "resall", "resany",
- "maxlstint", "laddr", "sort"):
+ "maxlstint", "laddr", "recent", "sort"):
continue
else:
raise ControlException(SERR_BADPARAM % k)
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bbf19159f6059039c42cbce3570a6397f3e290e4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161215/7bb0eb9f/attachment.html>
More information about the vc
mailing list