[Git][NTPsec/ntpsec][master] Fix maxpoll for refclocks.

Gary E. Miller gitlab at mg.gitlab.com
Mon Sep 26 20:00:55 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
0544f222 by Gary E. Miller at 2016-09-26T13:00:36-07:00
Fix maxpoll for refclocks.

An undefined maxpoll is not always set to the default maxpoll
(NTP_MAXDPOLL).  FOr a local refclock the default max poll is
the minpoll.

- - - - -


3 changed files:

- include/ntp.h
- ntpd/ntp_config.c
- ntpd/ntp_peer.c


Changes:

=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -98,6 +98,7 @@ typedef unsigned int	u_int;
 #define NTP_MINDPOLL	6	/* log2 default min poll (64 s) */
 #define NTP_MAXDPOLL	10	/* log2 default max poll (~17 m) */
 #define	NTP_MAXPOLL	17	/* log2 max poll interval (~36 h) */
+#define	NTP_MAXPOLL_UNK	99	/* log2 max poll unset */
 #define	NTP_RETRY	3	/* max packet retries */
 #define	NTP_MINPKT	2	/* guard time (s) */
 


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -626,7 +626,8 @@ create_peer_node(
 
 	my_node->ctl.version = NTP_VERSION;
 	my_node->ctl.minpoll = NTP_MINDPOLL;
-	my_node->ctl.maxpoll = NTP_MAXDPOLL;
+        /* can not set maxpoll default yet, it may be NTP_MAXDPOLL or minpoll */
+	my_node->ctl.maxpoll = NTP_MAXPOLL_UNK;
 
 	/* Now set the node to the read values */
 	my_node->host_mode = hmode;
@@ -2801,7 +2802,7 @@ config_peers(
 		struct peer_ctl client_ctl = {
 		    .version = NTP_VERSION,
 		    .minpoll = NTP_MINDPOLL,
-		    .maxpoll = NTP_MAXDPOLL,
+		    .maxpoll = NTP_MAXPOLL_UNK,
 		    .flags = FLAG_IBURST,
 		    .ttl = 0,
 		    .peerkey = 0,
@@ -2842,7 +2843,7 @@ config_peers(
 			ctx->host_mode = T_Server;
 			ctx->hmode = MODE_CLIENT;
 			ctx->ctl.flags   = FLAG_IBURST;
-			ctx->ctl.maxpoll = NTP_MAXDPOLL;
+			ctx->ctl.maxpoll = NTP_MAXPOLL_UNK;
 			ctx->ctl.minpoll = NTP_MINDPOLL;
 			ctx->ctl.peerkey = 0;
 			ctx->ctl.ttl     = 0;
@@ -2917,9 +2918,7 @@ config_peers(
 					 * timer, since the clock may
 					 * have requirements for this.
 					 */
-                                        /* FIXME: 0 no longer a magic value */
-                                        /* this needs to be fixed */
-					if (maxpoll == 0)
+					if (NTP_MAXPOLL_UNK == maxpoll)
 						/* default maxpoll for
 						 * refclocks is minpoll
 						 */


=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -762,6 +762,9 @@ newpeer(
 	set_peerdstadr(peer, 
 		       select_peerinterface(peer, srcadr, dstadr));
 
+        if (NTP_MAXPOLL_UNK == maxpoll)
+	    /* not set yet, set to default */
+	    peer->maxpoll = NTP_MAXDPOLL;
 	/*
          * minpoll is clamped not greater than NTP_MAXPOLL
          * maxpoll is clamped not less than NTP_MINPOLL



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/0544f2229822e89b8a62c2aa7659306593ff4a89
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160926/a2edd4cc/attachment.html>


More information about the vc mailing list