[Git][NTPsec/ntpsec][master] Revert all the way back to the last provably correct codfe transformation.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Jun 25 05:24:29 UTC 2016


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


Commits:
920df5b8 by Eric S. Raymond at 2016-06-25T01:22:13-04:00
Revert all the way back to the last provably correct codfe transformation.

The partial revert failed, producing a binary that crashes on startup.

- - - - -


8 changed files:

- docs/includes/ntpq-body.txt
- include/ntp_refclock.h
- ntpd/ntp_control.c
- ntpd/ntp_refclock.c
- ntpd/refclock_neoclock4x.c
- ntpd/refclock_parse.c
- ntpq/ntpq-subs.c
- ntpq/ntpq.c


Changes:

=====================================
docs/includes/ntpq-body.txt
=====================================
--- a/docs/includes/ntpq-body.txt
+++ b/docs/includes/ntpq-body.txt
@@ -541,15 +541,4 @@ some configurations.
 |+flags+       |driver flags
 |==========================================
 
-== Compatibility ==
-
-When listing refids, addresses of the form 127.127.x.x are no
-longer automatically interpreted as local refclocks as in older
-versons of +ntpq+.
-
-In some older versions, the 'type' variable associated with a
-reference clock was a numeric type index rather than an ASCII
-shortname for the driver type.  You may still see such numeric
-responses when querying legacy +ntpd+ implementations.
-
 // end


=====================================
include/ntp_refclock.h
=====================================
--- a/include/ntp_refclock.h
+++ b/include/ntp_refclock.h
@@ -66,6 +66,7 @@ extern struct clktype clktypes[];
  * Structure for returning clock status
  */
 struct refclockstat {
+	uint8_t	type;		/* clock type */
 	uint8_t	flags;		/* clock flags */
 	uint8_t	haveflags;	/* bit array of valid flags */
 	u_short	lencode;	/* length of last timecode */
@@ -75,7 +76,6 @@ struct refclockstat {
 	uint32_t	badformat;	/* bad format timecode received */
 	uint32_t	baddata;	/* invalid data timecode received */
 	uint32_t	timereset;	/* driver resets */
-	const char *clockname;	/* refclockname */
 	const char *clockdesc;	/* ASCII description */
 	double	fudgetime1;	/* configure fudge time1 */
 	double	fudgetime2;	/* configure fudge time2 */
@@ -152,6 +152,7 @@ struct refclockproc {
 	uint8_t	leap;		/* leap/synchronization code */
 	uint8_t	currentstatus;	/* clock status */
 	uint8_t	lastevent;	/* last exception event */
+	uint8_t	type;		/* clock type */
 	const char *clockname;	/* clock name (tag for logging) */
 	const char *clockdesc;	/* clock description */
 	u_long	nextaction;	/* local activity timeout */


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -269,9 +269,7 @@ static const struct ctl_proc control_codes[] = {
 #define	CP_SELDISP		48
 #define	CP_SELBROKEN		49
 #define	CP_CANDIDATE		50
-#define	CP_CLOCKTYPE		51
-#define	CP_CLOCKUNIT		52
-#define	CP_MAXCODE		CP_CLOCKUNIT
+#define	CP_MAXCODE		CP_CANDIDATE
 
 /*
  * Clock variables we understand
@@ -481,8 +479,6 @@ static const struct ctl_var peer_var[] = {
 	{ CP_SELDISP,	RO, "seldisp" },	/* 48 */
 	{ CP_SELBROKEN,	RO, "selbroken" },	/* 49 */
 	{ CP_CANDIDATE, RO, "candidate" },	/* 50 */
-	{ CP_CLOCKTYPE, RO, "clocktype" },	/* 51 */
-	{ CP_CLOCKUNIT, RO, "clockunit" },	/* 52 */
 	{ 0,		EOV, "" }		/* 50/58 */
 };
 
@@ -525,8 +521,6 @@ static const uint8_t def_peer_var[] = {
 	CP_FILTDELAY,
 	CP_FILTOFFSET,
 	CP_FILTERROR,
-	CP_CLOCKTYPE,
-	CP_CLOCKUNIT,
 	0
 };
 
@@ -2317,19 +2311,6 @@ ctl_putpeer(
 	case CP_CANDIDATE:
 		ctl_putuint(peer_var[id].text, p->status);
 		break;
-
-#ifdef REFCLOCK
-	case CP_CLOCKTYPE:
-		s = (char *)p->procptr->clockname;
-		s = s ? s : "";
-		ctl_putstr(peer_var[id].text, s, strlen(s));
-		break;
-
-	case CP_CLOCKUNIT:
-		ctl_putuint(peer_var[id].text, p->refclkunit);
-		break;
-#endif /* REFCLOCK */
-
 	default:
 		break;
 	}
@@ -2356,15 +2337,9 @@ ctl_putclock(
 	switch (id) {
 
 	case CC_TYPE:
-		if (pcs->clockname == NULL ||
-		    *(pcs->clockname) == '\0') {
-			if (mustput)
-				ctl_putstr(clock_var[id].text,
-					   "", 0);
-		} else {
-			ctl_putstr(clock_var[id].text,
-				   pcs->clockname,
-				   strlen(pcs->clockname));
+		if (mustput || pcs->clockdesc == NULL
+		    || *(pcs->clockdesc) == '\0') {
+			ctl_putuint(clock_var[id].text, pcs->type);
 		}
 		break;
 	case CC_TIMECODE:


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -207,6 +207,7 @@ refclock_newpeer(
 	peer->leap = LEAP_NOTINSYNC;
 	peer->stratum = STRATUM_REFCLOCK;
 	peer->ppoll = peer->maxpoll;
+	pp->type = clktype;
 	pp->conf = refclock_conf[clktype];
 	pp->timestarted = current_time;
 	pp->io.fd = -1;
@@ -1025,7 +1026,7 @@ refclock_control(
 
 		out->lastevent = pp->lastevent;
 		out->currentstatus = pp->currentstatus;
-		out->clockname = pp->clockname;
+		out->type = pp->type;
 		out->clockdesc = pp->clockdesc;
 		out->lencode = (u_short)pp->lencode;
 		out->p_lastcode = pp->a_lastcode;


=====================================
ntpd/refclock_neoclock4x.c
=====================================
--- a/ntpd/refclock_neoclock4x.c
+++ b/ntpd/refclock_neoclock4x.c
@@ -657,6 +657,7 @@ neoclock4x_control(int unit,
       char tmpbuf[80];
 
       out->kv_list = (struct ctl_var *)0;
+      out->type    = REFCLK_NEOCLOCK4X;
 
       snprintf(tmpbuf, sizeof(tmpbuf)-1,
 	       "%04d-%02d-%02d %02d:%02d:%02d.%03d",


=====================================
ntpd/refclock_parse.c
=====================================
--- a/ntpd/refclock_parse.c
+++ b/ntpd/refclock_parse.c
@@ -3017,6 +3017,8 @@ parse_control(
 
 		outstatus[0] = '\0';
 
+		out->type       = REFCLK_PARSE;
+
 		/*
 		 * keep fudgetime2 in sync with TRUSTTIME/MAXUNSYNC flag1
 		 */


=====================================
ntpq/ntpq-subs.c
=====================================
--- a/ntpq/ntpq-subs.c
+++ b/ntpq/ntpq-subs.c
@@ -1658,6 +1658,9 @@ doprintpeers(
 				} else if (decodenetnum(value, &refidadr)) {
 					if (SOCK_UNSPEC(&refidadr))
 						dstadr_refid = "0.0.0.0";
+					else if (ISREFCLOCKADR(&refidadr))
+						dstadr_refid =
+						    refnumtoa(&refidadr);
 					else
 						dstadr_refid =
 						    stoa(&refidadr);
@@ -1677,6 +1680,9 @@ doprintpeers(
 				} else if (decodenetnum(value, &refidadr)) {
 					if (SOCK_UNSPEC(&refidadr))
 						dstadr_refid = "0.0.0.0";
+					else if (ISREFCLOCKADR(&refidadr))
+						dstadr_refid =
+						    refnumtoa(&refidadr);
 					else {
 						char *buf = emalloc(10);
 						int i = ntohl(refidadr.sa4.sin_addr.s_addr);


=====================================
ntpq/ntpq.c
=====================================
--- a/ntpq/ntpq.c
+++ b/ntpq/ntpq.c
@@ -3268,7 +3268,11 @@ cookedprint(
 
 		case RF:
 			if (decodenetnum(value, &hval)) {
-			    output(fp, name, stoa(&hval));
+				if (ISREFCLOCKADR(&hval))
+					output(fp, name,
+					       refnumtoa(&hval));
+				else
+					output(fp, name, stoa(&hval));
 			} else if (strlen(value) <= 4) {
 				output(fp, name, value);
 			} else {



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


More information about the vc mailing list