[Git][NTPsec/ntpsec][master] Refclocks work again, with IS_PEER_REFCLOCK changes mostly restored.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Jun 22 20:08:06 UTC 2016


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


Commits:
6c3f1f06 by Eric S. Raymond at 2016-06-22T16:05:59-04:00
Refclocks work again, with IS_PEER_REFCLOCK changes mostly restored.

- - - - -


5 changed files:

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


Changes:

=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -232,6 +232,15 @@ 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 interpretted as
+ * some sanity checks to make sure this address isn't interpreted 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 (ISREFCLOCKADR(&peer->srcadr))
+		if (IS_PEER_REFCLOCK(peer))
 			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 (ISREFCLOCKADR(srcadr)) {
+	if (IS_PEER_REFCLOCK(peer)) {
 		ep = loopback_interface;
 	} else if (peer->cast_flags &
 		   (MDF_BCLNT | MDF_ACAST | MDF_MCAST | MDF_BCAST)) {


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -961,19 +961,17 @@ 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;
 
-	NTP_INSIST(peer->procptr != NULL);
+	if (!IS_PEER_REFCLOCK(peer))
+		return;
+
 	pp = peer->procptr;
+	clktype = peer->refclktype;
+	unit = peer->refclkunit;
 
 	/*
 	 * Initialize requested data
@@ -1070,20 +1068,19 @@ refclock_buginfo(
 	unsigned u;
 
 	/*
-	 * Check for valid address and peer structure
+	 * Check for valid peer structure and address
 	 */
-	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/6c3f1f063feb97332a8a86b96e9a10ddd2c898ab
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160622/b2a667c0/attachment.html>


More information about the vc mailing list