[Git][NTPsec/ntpsec][master] Cerect redclock packets by absence of dstadr, not magic address format.

Eric S. Raymond gitlab at mg.gitlab.com
Fri Jun 24 02:15:39 UTC 2016


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


Commits:
a9aa6b0e by Eric S. Raymond at 2016-06-23T22:14:33-04:00
Cerect redclock packets by absence of dstadr, not magic address format.

- - - - -


3 changed files:

- include/recvbuff.h
- ntpd/ntp_io.c
- ntpd/ntp_proto.c


Changes:

=====================================
include/recvbuff.h
=====================================
--- a/include/recvbuff.h
+++ b/include/recvbuff.h
@@ -76,6 +76,8 @@ struct recvbuf {
 	int used;		/* reference count */
 };
 
+#define is_refclock_packet(rbufp)	((rbufp)->dstadr == NULL)
+
 extern	void	init_recvbuff(int);
 
 /* freerecvbuf - make a single recvbuf available for reuse


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3281,7 +3281,7 @@ read_refclock_packet(
 	 */
 	rb->recv_length = buflen;
 	rb->recv_peer = rp->srcclock;
-	rb->dstadr = 0;
+	rb->dstadr = NULL;	/* see is_refclock_packet() */
 	rb->cast_flags = 0;
 	rb->fd = fd;
 	rb->recv_time = ts;


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -587,7 +587,7 @@ receive(
 	 * active refclock node, drop it. This replaces the old style of
 	 * looking for a magic address prefix.
 	 */
-	if (peer && IS_PEER_REFCLOCK(peer) && rbufp->dstadr != 0)
+	if (IS_PEER_REFCLOCK(peer) && !is_refclock_packet(rbufp))
 	{
 	    msyslog(LOG_ERR, "refclock srcadr on a network interface (%s)!",
 		    stoa(&peer->srcadr));
@@ -805,7 +805,7 @@ receive(
 			       peer2->maxpoll, FLAG_PREEMPT |
 			       (FLAG_IBURST & peer2->flags), MDF_UCAST |
 			       MDF_UCLNT, 0, skeyid,
-			       ISREFCLOCKADR(&rbufp->recv_srcadr));
+			       is_refclock_packet(rbufp));
 		if (NULL == peer) {
 			sys_declined++;
 			return;			/* ignore duplicate  */
@@ -883,7 +883,7 @@ receive(
 			    match_ep, MODE_BCLIENT, hisversion,
 			    pkt->ppoll, pkt->ppoll, FLAG_PREEMPT,
 			    MDF_BCLNT, 0, skeyid,
-			    ISREFCLOCKADR(&rbufp->recv_srcadr));
+			    is_refclock_packet(rbufp));
 			if (NULL == peer) {
 				sys_restricted++;
 				return;		/* ignore duplicate */
@@ -906,7 +906,7 @@ receive(
 		peer = newpeer(&rbufp->recv_srcadr, NULL, match_ep,
 		    MODE_CLIENT, hisversion, pkt->ppoll, pkt->ppoll,
 		    FLAG_BC_VOL | FLAG_IBURST | FLAG_PREEMPT, MDF_BCLNT,
-		    0, skeyid, ISREFCLOCKADR(&rbufp->recv_srcadr));
+		    0, skeyid, is_refclock_packet(rbufp));
 		if (NULL == peer) {
 			sys_restricted++;
 			return;			/* ignore duplicate */
@@ -990,7 +990,7 @@ receive(
 		if ((peer = newpeer(&rbufp->recv_srcadr, NULL,
 		    rbufp->dstadr, MODE_PASSIVE, hisversion, pkt->ppoll,
 				    NTP_MAXDPOLL, 0, MDF_UCAST, 0, skeyid,
-				    ISREFCLOCKADR(&rbufp->recv_srcadr))) == NULL) {
+				    is_refclock_packet(rbufp))) == NULL) {
 			sys_declined++;
 			return;			/* ignore duplicate */
 		}



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


More information about the vc mailing list