[Git][NTPsec/ntpsec][master] 2 commits: The source designator in clockstats...

Eric S. Raymond gitlab at mg.gitlab.com
Mon Dec 12 11:56:18 UTC 2016


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


Commits:
ef1bdb44 by Eric S. Raymond at 2016-12-12T06:56:07-05:00
The source designator in clockstats...

...is no longer necessarily an IP address.

- - - - -
bc92e923 by Eric S. Raymond at 2016-12-12T06:56:07-05:00
Make shm report POSIX seconds since epoch, not calendar time.

There is both a philosophical and a practical point to this change.
The philosophical point is that the device driver logging should
report what it actually *knows*, not add a whole layer of
interpretation that is potebtially buggy.  The practical point is that
we are trying to narrow the cope of use of the homebrew vint64 type
preparatory to abolishing it.

- - - - -


2 changed files:

- docs/driver_shm.txt
- ntpd/refclock_shm.c


Changes:

=====================================
docs/driver_shm.txt
=====================================
--- a/docs/driver_shm.txt
+++ b/docs/driver_shm.txt
@@ -102,8 +102,8 @@ with the PPS events.
 == Clockstats ==
 
 If flag4 is set when the driver is polled, a clockstats record is
-written. The first 3 fields are the normal date, time, and IP address
-common to all clockstats records.
+written. The first 3 fields are the normal date, time, and source
+designator common to all clockstats records.
 
 The 4th field is the number of second ticks since the last poll. The 5th
 field is the number of good data samples found. The last 64 will be used


=====================================
ntpd/refclock_shm.c
=====================================
--- a/ntpd/refclock_shm.c
+++ b/ntpd/refclock_shm.c
@@ -459,11 +459,7 @@ shm_timer(
 	l_fp tsrcv;
 	l_fp tsref;
 	int c;
-
-	/* for formatting 'a_lastcode': */
-	struct calendar cd;
 	time_t tt;
-	vint64 ts;
 
 	enum segstat_t status;
 	struct shm_stat_t shm_stat;
@@ -516,22 +512,14 @@ shm_timer(
 	}
 
 
-	/* format the last time code in human-readable form into
-	 * 'pp->a_lastcode'. Someone claimed: "NetBSD has incompatible
-	 * tv_sec". I can't find a base for this claim, but we can work
-	 * around that potential problem. BTW, simply casting a pointer
-	 * is a receipe for disaster on some architectures.
+	/*
+	 * Add POSIX UTC seconds and fractional seconds as a timecode.
+	 * We used to unpack this to calendar time, but it is bad
+	 * practice for the driver to pretend to know calendar time;
+	 * that interpretation is best left to higher levels.
 	 */
-	tt = (time_t)shm_stat.tvt.tv_sec;
-	ts = time_to_vint64(&tt);
-	ntpcal_time_to_date(&cd, &ts);
-		
-	/* add ntpq -c cv timecode in ISO 8601 format */
 	c = snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
-		     "%04u-%02u-%02uT%02u:%02u:%02u.%09ldZ",
-		     cd.year, cd.month, cd.monthday,
-		     cd.hour, cd.minute, cd.second,
-		     shm_stat.tvt.tv_nsec);
+		     "%ld.%09ld", shm_stat.tvt.tv_sec,	shm_stat.tvt.tv_nsec);
 	pp->lencode = (c < (int)sizeof(pp->a_lastcode)) ? c : 0;
 
 	/* check 1: age control of local time stamp */



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/c07f1f180f74a15721d6a98cf3f84e7245c0cb12...bc92e9233db232ac096ec7fee14961dfd7a9c881
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161212/31b2f1ae/attachment.html>


More information about the vc mailing list