[Git][NTPsec/ntpsec][master] Partially revert magic-number changes - something in them busted refclocks.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Jun 22 18:20:24 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a1b4ba59 by Eric S. Raymond at 2016-06-22T14:19:05-04:00
Partially revert magic-number changes - something in them busted refclocks.

- - - - -


6 changed files:

- include/ntp.h
- include/ntp_net.h
- ntpd/ntp_control.c
- ntpd/ntp_io.c
- ntpd/ntp_peer.c
- ntpd/ntp_refclock.c


Changes:

=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -232,15 +232,6 @@ struct interface {
 #define	PEER_BOGON_MASK	(BOGON10 | BOGON11 | BOGON12 | BOGON13)
 
 /*
- * Does a peer node represent a reference clock?
- */
-#ifdef REFCLOCK
-#define IS_PEER_REFCLOCK(p)	((p)->procptr != NULL)
-#else
-#define IS_PEER_REFCLOCK(p)	false
-#endif
-
-/*
  * The peer structure. Holds state information relating to the guys
  * we are peering with. Most of this stuff is from section 3.2 of the
  * spec.


=====================================
include/ntp_net.h
=====================================
--- a/include/ntp_net.h
+++ b/include/ntp_net.h
@@ -198,7 +198,7 @@ typedef union {
  * We tell reference clocks from real peers by giving the reference
  * clocks an address of the form 127.127.t.u, where t is the type and
  * u is the unit number.  We define some of this here since we will need
- * some sanity checks to make sure this address isn't interpreted as
+ * some sanity checks to make sure this address isn't interpretted as
  * that of a normal peer.
  */
 #define	REFCLOCK_ADDR	0x7f7f0000	/* 127.127.0.0 */


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -4357,7 +4357,7 @@ report_event(
 		peer->last_event = errlast;
 		peer->num_events++;
 #ifdef REFCLOCK
-		if (IS_PEER_REFCLOCK(peer))
+		if (ISREFCLOCKADR(&peer->srcadr))
 			src = refclock_name(peer);
 		else
 #endif /* REFCLOCK */ 


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3864,7 +3864,7 @@ select_peerinterface(
 	 * This might happen in some systems and would preclude proper
 	 * operation with public key cryptography.
 	 */
-	if (IS_PEER_REFCLOCK(peer)) {
+	if (ISREFCLOCKADR(srcadr)) {
 		ep = loopback_interface;
 	} else if (peer->cast_flags &
 		   (MDF_BCLNT | MDF_ACAST | MDF_MCAST | MDF_BCAST)) {


=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -884,7 +884,7 @@ newpeer(
 	peer->timereachable = current_time;
 	peer->timereceived = current_time;
 
-	if (IS_PEER_REFCLOCK(peer)) {
+	if (ISREFCLOCKADR(&peer->srcadr)) {
 #ifdef REFCLOCK
 		/*
 		 * We let the reference clock support do clock


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -184,7 +184,7 @@ refclock_newpeer(
 	 * Check for valid clock address. If already running, shut it
 	 * down first.
 	 */
-	if (!IS_PEER_REFCLOCK(peer)) {
+	if (!ISREFCLOCKADR(&peer->srcadr)) {
 		msyslog(LOG_ERR,
 			"refclock_newpeer: clock address %s invalid",
 			stoa(&peer->srcadr));
@@ -961,17 +961,19 @@ refclock_control(
 	/*
 	 * Check for valid address and running peer
 	 */
+	if (!ISREFCLOCKADR(srcadr))
+		return;
+
+	clktype = (uint8_t)REFCLOCKTYPE(srcadr);
+	unit = REFCLOCKUNIT(srcadr);
+
 	peer = findexistingpeer(srcadr, NULL, NULL, -1, 0);
 
 	if (NULL == peer)
 		return;
 
-	if (!IS_PEER_REFCLOCK(peer))
-		return;
-
+	NTP_INSIST(peer->procptr != NULL);
 	pp = peer->procptr;
-	clktype = peer->refclktype;
-	unit = peer->refclkunit;
 
 	/*
 	 * Initialize requested data
@@ -1068,19 +1070,20 @@ refclock_buginfo(
 	unsigned u;
 
 	/*
-	 * Check for valid peer structure and address
+	 * Check for valid address and peer structure
 	 */
+	if (!ISREFCLOCKADR(srcadr))
+		return;
+
+	clktype = (uint8_t) REFCLOCKTYPE(srcadr);
+	unit = REFCLOCKUNIT(srcadr);
+
 	peer = findexistingpeer(srcadr, NULL, NULL, -1, 0);
 
 	if (NULL == peer || NULL == peer->procptr)
 		return;
 
 	pp = peer->procptr;
-	if (pp == NULL)
-	    return;
-
-	clktype = peer->refclktype;
-	unit = peer->refclkunit;
 
 	/*
 	 * Copy structure values



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a1b4ba59efd6881ed8cc4549b5a9bfcbc1297981
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160622/4f1b6c45/attachment.html>


More information about the vc mailing list