[Git][NTPsec/ntpsec][master] Addressing GitLab Issue #108, add a "tos maxdisp" configuration command.
Eric S. Raymond
gitlab at mg.gitlab.com
Fri Oct 7 17:35:20 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
c14ef341 by Eric S. Raymond at 2016-10-07T13:34:05-04:00
Addressing GitLab Issue #108, add a "tos maxdisp" configuration command.
- - - - -
12 changed files:
- docs/index.txt
- docs/miscopt.txt
- include/ntp.h
- include/ntpd.h
- ntpd/keyword-gen.c
- ntpd/ntp_config.c
- ntpd/ntp_loopfilter.c
- ntpd/ntp_parser.y
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/refclock_arbiter.c
- ntpd/refclock_spectracom.c
Changes:
=====================================
docs/index.txt
=====================================
--- a/docs/index.txt
+++ b/docs/index.txt
@@ -150,6 +150,10 @@ few will be user-visible.
in /etc/ntp.conf finding /etc/foo rather than looking for foo in
ypur current directory.
+* It is now possible to set the peer maximum dispersion with "tos
+ maxdisp". See RFC5905 for discussion of this synchronization
+ parameter.
+
* For the generic (parse) driver only: Using the new refclock syntax,
the maximum number of units that can be set up changes from 4
(numbers 0-3) to unlimited. However, the old magic-address syntax
=====================================
docs/miscopt.txt
=====================================
--- a/docs/miscopt.txt
+++ b/docs/miscopt.txt
@@ -61,6 +61,10 @@ include::includes/misc-options.txt[]
minimum number of packets to set the system clock and the maximum
roundtrip delay. It can be decreased to improve reliability or
increased to synchronize clocks on the Moon or planets.
+ +maxdisp+ 'maxdispersion';;
+ Specify the maximum dispersion used by the clock synchronization
+ algorithm. The default is 16s. This is also the dispersion
+ assigned to missing data. See RFC5905 for discussion.
+minclock+ 'minclock';;
Specify the number of servers used by the clustering algorithm as
the minimum to include on the candidate list. The default is 3. This
=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -621,7 +621,7 @@ struct pkt {
#define PROTO_CALLDELAY 20
#define PROTO_MINDISP 21
#define PROTO_MAXDIST 22
- /* available 23 */
+#define PROTO_MAXDISP 23
#define PROTO_MAXHOP 24
#define PROTO_BEACON 25
#define PROTO_ORPHAN 26
=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -180,6 +180,7 @@ extern int leapdif; /* TAI difference step at next leap second*/
extern int sys_orphan;
extern double sys_mindisp;
extern double sys_maxdist;
+extern double sys_maxdisp;
extern void poll_update (struct peer *, uint8_t);
=====================================
ntpd/keyword-gen.c
=====================================
--- a/ntpd/keyword-gen.c
+++ b/ntpd/keyword-gen.c
@@ -135,6 +135,7 @@ struct key_tok ntp_keywords[] = {
{ "ceiling", T_Ceiling, FOLLBY_TOKEN },
{ "cohort", T_Cohort, FOLLBY_TOKEN },
{ "mindist", T_Mindist, FOLLBY_TOKEN },
+{ "maxdisp", T_Maxdisp, FOLLBY_TOKEN },
{ "maxdist", T_Maxdist, FOLLBY_TOKEN },
{ "beacon", T_Beacon, FOLLBY_TOKEN },
{ "orphan", T_Orphan, FOLLBY_TOKEN },
=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -1360,6 +1360,10 @@ config_tos(
item = PROTO_MINDISP;
break;
+ case T_Maxdisp:
+ item = PROTO_MAXDISP;
+ break;
+
case T_Maxdist:
item = PROTO_MAXDIST;
break;
=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -1121,8 +1121,8 @@ start_kern_loop(void)
ZERO(ntv);
ntv.modes = MOD_BITS;
ntv.status = STA_PLL;
- ntv.maxerror = MAXDISPERSE;
- ntv.esterror = MAXDISPERSE;
+ ntv.maxerror = sys_maxdisp;
+ ntv.esterror = sys_maxdisp;
ntv.constant = sys_poll; /* why is it that here constant is unconditionally set to sys_poll, whereas elsewhere is is modified depending on nanosecond vs. microsecond kernel? */
#ifdef SIGSYS
/*
=====================================
ntpd/ntp_parser.y
=====================================
--- a/ntpd/ntp_parser.y
+++ b/ntpd/ntp_parser.y
@@ -135,6 +135,7 @@
%token <Integer> T_Maxage
%token <Integer> T_Maxclock
%token <Integer> T_Maxdepth
+%token <Integer> T_Maxdisp
%token <Integer> T_Maxdist
%token <Integer> T_Maxmem
%token <Integer> T_Maxpoll
@@ -638,6 +639,7 @@ tos_option_int_keyword
tos_option_dbl_keyword
: T_Mindist
+ | T_Maxdisp
| T_Maxdist
| T_Minclock
| T_Maxclock
=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -81,6 +81,7 @@ l_fp sys_authdelay; /* authentication delay */
double sys_offset; /* current local clock offset */
double sys_mindisp = MINDISPERSE; /* minimum distance (s) */
double sys_maxdist = MAXDISTANCE; /* selection threshold */
+double sys_maxdisp = MAXDISPERSE; /* maximum dspersion */
double sys_jitter; /* system jitter */
u_long sys_epoch; /* last clock update time */
static double sys_clockhop; /* clockhop threshold */
@@ -598,7 +599,7 @@ handle_procpkt(
}
if(scalbn((double)pkt->rootdelay/2.0 + (double)pkt->rootdisp, -16) >=
- MAXDISPERSE) {
+ sys_maxdisp) {
peer->flash |= BOGON7;
return;
}
@@ -728,7 +729,7 @@ handle_manycast(
PKT_TO_STRATUM(pkt->stratum) < sys_floor ||
PKT_TO_STRATUM(pkt->stratum) >= sys_ceiling ||
scalbn((double)pkt->rootdelay/2.0 + (double)pkt->rootdisp, -16) >=
- MAXDISPERSE) {
+ sys_maxdisp) {
return;
}
@@ -942,7 +943,7 @@ transmit(
* previously reachable raise a trap. Send a
* burst if enabled.
*/
- clock_filter(peer, 0., 0., MAXDISPERSE);
+ clock_filter(peer, 0., 0., sys_maxdisp);
if (oreach) {
peer_unfit(peer);
report_event(PEVNT_UNREACH, peer, NULL);
@@ -1315,7 +1316,7 @@ peer_clear(
memset(CLEAR_TO_ZERO(peer), 0, LEN_CLEAR_TO_ZERO(peer));
peer->ppoll = peer->maxpoll;
peer->hpoll = peer->minpoll;
- peer->disp = MAXDISPERSE;
+ peer->disp = sys_maxdisp;
peer->flash = peer_unfit(peer);
peer->jitter = LOGTOD(sys_precision);
@@ -1326,7 +1327,7 @@ peer_clear(
for (u = 0; u < NTP_SHIFT; u++) {
peer->filter_order[u] = u;
- peer->filter_disp[u] = MAXDISPERSE;
+ peer->filter_disp[u] = sys_maxdisp;
}
#ifdef REFCLOCK
if (!(peer->flags & FLAG_REFCLOCK)) {
@@ -1426,9 +1427,9 @@ clock_filter(
for (i = NTP_SHIFT - 1; i >= 0; i--) {
if (i != 0)
peer->filter_disp[j] += dtemp;
- if (peer->filter_disp[j] >= MAXDISPERSE) {
- peer->filter_disp[j] = MAXDISPERSE;
- dst[i] = MAXDISPERSE;
+ if (peer->filter_disp[j] >= sys_maxdisp) {
+ peer->filter_disp[j] = sys_maxdisp;
+ dst[i] = sys_maxdisp;
} else if (peer->update - peer->filter_epoch[j] >
(u_long)ULOGTOD(allan_xpt)) {
dst[i] = peer->filter_delay[j] +
@@ -1470,7 +1471,7 @@ clock_filter(
m = 0;
for (i = 0; i < NTP_SHIFT; i++) {
peer->filter_order[i] = (uint8_t) ord[i];
- if (dst[i] >= MAXDISPERSE || (m >= 2 && dst[i] >=
+ if (dst[i] >= sys_maxdisp || (m >= 2 && dst[i] >=
sys_maxdist))
continue;
m++;
@@ -2928,6 +2929,10 @@ proto_config(
sys_maxclock = (int)dvalue;
break;
+ case PROTO_MAXDISP: /* maximum dispersion (maxdisp) */
+ sys_maxdisp = dvalue;
+ break;
+
case PROTO_MAXDIST: /* select threshold (maxdist) */
sys_maxdist = dvalue;
break;
=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -303,7 +303,7 @@ refclock_transmit(
oreach = peer->reach & 0xfe;
peer->reach <<= 1;
if (!(peer->reach & 0x0f))
- clock_filter(peer, 0., 0., MAXDISPERSE);
+ clock_filter(peer, 0., 0., sys_maxdisp);
peer->outdate = current_time;
if (!peer->reach) {
if (oreach) {
=====================================
ntpd/refclock_arbiter.c
=====================================
--- a/ntpd/refclock_arbiter.c
+++ b/ntpd/refclock_arbiter.c
@@ -390,13 +390,13 @@ arb_receive(
break;
case 'F': /* clock failure */
- pp->disp = MAXDISPERSE;
+ pp->disp = sys_maxdisp;
refclock_report(peer, CEVNT_FAULT);
IGNORE(write(pp->io.fd, COMMAND_HALT_BCAST, 2));
return;
default:
- pp->disp = MAXDISPERSE;
+ pp->disp = sys_maxdisp;
refclock_report(peer, CEVNT_BADREPLY);
IGNORE(write(pp->io.fd, COMMAND_HALT_BCAST, 2));
return;
=====================================
ntpd/refclock_spectracom.c
=====================================
--- a/ntpd/refclock_spectracom.c
+++ b/ntpd/refclock_spectracom.c
@@ -403,11 +403,11 @@ spectracom_receive(
break;
case 'D':
- pp->disp = MAXDISPERSE;
+ pp->disp = sys_maxdisp;
break;
default:
- pp->disp = MAXDISPERSE;
+ pp->disp = sys_maxdisp;
refclock_report(peer, CEVNT_BADREPLY);
break;
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c14ef3417f245e730c272d86386edadb94cf1d4e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161007/740ddd46/attachment.html>
More information about the vc
mailing list