[Git][NTPsec/ntpsec][master] Address GitLab issue #452: Add root_distance to variables accessible via mode 6.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Jan 25 20:25:33 UTC 2018


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


Commits:
1f556dd3 by Eric S. Raymond at 2018-01-25T15:22:42-05:00
Address GitLab issue #452: Add root_distance to variables accessible via mode 6.

This is to support the SNMP MIB.  The system root distance is that of the select
peer.

- - - - -


3 changed files:

- include/ntpd.h
- ntpd/ntp_control.c
- ntpd/ntp_proto.c


Changes:

=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -321,6 +321,7 @@ extern uint8_t	sys_stratum;		/* system stratum */
 extern int8_t	sys_precision;		/* local clock precision */
 extern double	sys_rootdelay;		/* roundtrip delay to primary source */
 extern double	sys_rootdisp;		/* dispersion to primary source */
+extern double	sys_rootdist;		/* distance to primaet source */
 extern uint32_t	sys_refid;		/* reference id */
 extern l_fp	sys_reftime;		/* last update time */
 extern struct peer *sys_peer;		/* current peer */


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -223,7 +223,8 @@ static const struct ctl_proc control_codes[] = {
 #define	CS_LEAPSMEAROFFS	97
 #define	CS_TICK                 98
 #define	CS_NUMCTLREQ		99
-#define	CS_MAXCODE		CS_NUMCTLREQ
+#define CS_ROOTDISTANCE		100
+#define	CS_MAXCODE		CS_ROOTDISTANCE
 
 /*
  * Peer variables we understand
@@ -404,7 +405,8 @@ static const struct ctl_var sys_var[] = {
 	{ CS_TICK,		RO, "tick" },		/* 98 */
 	/* new in NTPsec */
 	{ CS_NUMCTLREQ,		RO, "ss_numctlreq" },	/* 99 */
-	{ 0,                    EOV, "" }		/* 99 */
+	{ CS_ROOTDISTANCE,	RO, "rootdist" },	/* 100 */
+	{ 0,                    EOV, "" }
 };
 
 static struct ctl_var *ext_sys_var = NULL;
@@ -2004,6 +2006,11 @@ ctl_putsys(
 		ctl_putuint(sys_var[varid].text, numctlreq);
 		break;
 
+	case CS_ROOTDISTANCE:
+		ctl_putdbl(sys_var[CS_ROOTDISTANCE].text,
+			   sys_rootdist * MS_PER_S);
+		break;
+
         default:
                 /* huh? */
                 break;


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -103,6 +103,7 @@ uint8_t	sys_stratum;		/* system stratum */
 int8_t	sys_precision;		/* local clock precision (log2 s) */
 double	sys_rootdelay;		/* roundtrip delay to primary source */
 double	sys_rootdisp;		/* dispersion to primary source */
+double	sys_rootdist;		/* only used fror Mode 6 export */
 uint32_t sys_refid;		/* reference id (network byte order) */
 l_fp	sys_reftime;		/* last update time */
 struct	peer *sys_peer;		/* current peer */
@@ -2022,7 +2023,7 @@ clock_select(void)
 	 * Mitigation rules of the game. We have the pick of the
 	 * litter in typesystem if any survivors are left. If
 	 * there is a prefer peer, use its offset and jitter.
-	 * Otherwise, use the combined offset and jitter of all kitters.
+	 * Otherwise, use the combined offset and jitter of all kittens.
 	 */
 	if (typesystem != NULL) {
 		if (sys_prefer == NULL) {
@@ -2034,6 +2035,7 @@ clock_select(void)
 			typesystem->new_status = CTL_PST_SEL_SYSPEER;
 			sys_offset = typesystem->offset;
 			sys_jitter = typesystem->jitter;
+			sys_rootdist = root_distance(typesystem);
 		}
 		DPRINT(1, ("select: combine offset %.9f jitter %.9f\n",
 			   sys_offset, sys_jitter));
@@ -2055,6 +2057,7 @@ clock_select(void)
 		typesystem->new_status = CTL_PST_SEL_PPS;
 		sys_offset = typesystem->offset;
 		sys_jitter = typesystem->jitter;
+		sys_rootdist = root_distance(typesystem);
 		DPRINT(1, ("select: pps offset %.9f jitter %.9f\n",
 			   sys_offset, sys_jitter));
 	} else if ( typepps &&



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/1f556dd33d58ca1250fa622467864364a9fb1843

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/1f556dd33d58ca1250fa622467864364a9fb1843
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180125/54c4eb79/attachment.html>


More information about the vc mailing list