[Git][NTPsec/ntpsec][master] Address GitLab issue #330: no common notation for refclock
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Aug 8 12:39:22 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
842aa411 by Eric S. Raymond at 2017-08-08T08:39:09-04:00
Address GitLab issue #330: no common notation for refclock
Carries through the use of driver-unit pairs (rather than magic addresses)
as device identifiers, in the peerstats and rawstats files. The
clockstats file had already been converted.
- - - - -
4 changed files:
- docs/ntpsec.txt
- include/ntpd.h
- ntpd/ntp_proto.c
- ntpd/ntp_util.c
Changes:
=====================================
docs/ntpsec.txt
=====================================
--- a/docs/ntpsec.txt
+++ b/docs/ntpsec.txt
@@ -64,7 +64,8 @@ a build-time switch, not a run-time one).
* Clock identifiers in log files are normally the driver shortname
followed by the unit number in parentheses, rather than the magic IP
- addresses formerly used. Reverted in the --enable-classic-mode build.
+ addresses formerly used. This change affects the peerstats, rawstats,
+ and clockstats files. Reverted in the --enable-classic-mode build.
* The -!m, -\>, and -< options of some Classic commands are not
supported. (The argument-parsing framework code that implemented
=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -191,7 +191,11 @@ extern void record_loop_stats (double, double, double, double, int);
extern void record_clock_stats (struct peer *, const char *);
extern int mprintf_clock_stats(struct peer *, const char *, ...)
NTP_PRINTF(2, 3);
-extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, uint32_t refid, u_int outcount);
+extern void record_raw_stats (struct peer *,
+ int leap, int version, int mode, int stratum,
+ int ppoll, int precision, double root_delay,
+ double root_dispersion, uint32_t refid,
+ u_int outcount);
extern void check_leap_file (bool is_daily_check, time_t systime);
#ifdef ENABLE_DEBUG_TIMING
extern void record_timing_stats (const char *);
=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -665,15 +665,14 @@ handle_procpkt(
peer->xmt = pkt->xmt;
peer->dst = rbufp->recv_time;
- record_raw_stats(&peer->srcadr,
- peer->dstadr ? &peer->dstadr->sin : NULL,
- /* What we want to be reporting is values in the packet,
- not the values in the peer structure, but when we
- reach here they're the same thing. Passing the values
- in the peer structure is a convenience, because
+ record_raw_stats(peer,
+ /* What we want to be reporting is values in
+ the packet, not the values in the peer
+ structure, but when we reach here they're
+ the same thing. Passing the values in the
+ peer structure is a convenience, because
they're already in the l_fp format that
record_raw_stats() expects. */
- &peer->org, &peer->rec, &peer->xmt, &peer->dst,
PKT_LEAP(pkt->li_vn_mode),
PKT_VERSION(pkt->li_vn_mode),
PKT_MODE(pkt->li_vn_mode),
=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -364,6 +364,17 @@ timespec_to_MJDtime(const struct timespec *ts)
}
+static const char *
+peerlabel(const struct peer *peer)
+{
+#if defined(REFCLOCK) && !defined(ENABLE_CLASSIC_MODE)
+ if (peer->procptr != NULL)
+ return refclock_name(peer);
+ else
+#endif /* defined(REFCLOCK) && !defined(ENABLE_CLASSIC_MODE)*/
+ return socktoa(&peer->srcadr);
+}
+
/*
* record_peer_stats - write peer statistics to file
*
@@ -394,23 +405,12 @@ record_peer_stats(
fprintf(peerstats.fp,
"%s %s %x %.9f %.9f %.9f %.9f\n",
timespec_to_MJDtime(&now),
- socktoa(&peer->srcadr), (u_int)status, peer->offset,
+ peerlabel(peer), (u_int)status, peer->offset,
peer->delay, peer->disp, peer->jitter);
fflush(peerstats.fp);
}
}
-static const char *
-peerlabel(const struct peer *peer)
-{
-#if defined(REFCLOCK) && !defined(ENABLE_CLASSIC_MODE)
- if (peer->procptr != NULL)
- return refclock_name(peer);
- else
-#endif /* defined(REFCLOCK) && !defined(ENABLE_CLASSIC_MODE)*/
- return socktoa(&peer->srcadr);
-}
-
/*
* record_loop_stats - write loop filter statistics to file
*
@@ -509,18 +509,14 @@ mprintf_clock_stats(
* file format
* day (MJD)
* time (s past midnight)
- * peer ip address
- * IP address old format) or drivername(unit) (new format)
+ * source IP address old format) or drivername(unit) (new format)
+ * destination peer address
* t1 t2 t3 t4 timestamps
+ * various other local statistics
*/
void
record_raw_stats(
- sockaddr_u *srcadr,
- sockaddr_u *dstadr,
- l_fp *t1, /* originate timestamp */
- l_fp *t2, /* receive timestamp */
- l_fp *t3, /* transmit timestamp */
- l_fp *t4, /* destination timestamp */
+ struct peer *peer,
int leap,
int version,
int mode,
@@ -534,6 +530,11 @@ record_raw_stats(
)
{
struct timespec now;
+ const sockaddr_u *dstaddr = peer->dstadr ? &peer->dstadr->sin : NULL;
+ l_fp t1 = peer->org; /* originate timestamp */
+ l_fp t2 = peer->rec; /* receive timestamp */
+ l_fp t3 = peer->xmt; /* transmit timestamp */
+ l_fp t4 = peer->dst; /* destination timestamp */
if (!stats_control)
return;
@@ -543,9 +544,9 @@ record_raw_stats(
if (rawstats.fp != NULL) {
fprintf(rawstats.fp, "%s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s %u\n",
timespec_to_MJDtime(&now),
- socktoa(srcadr), dstadr ? socktoa(dstadr) : "-",
- ulfptoa(*t1, 9), ulfptoa(*t2, 9),
- ulfptoa(*t3, 9), ulfptoa(*t4, 9),
+ peerlabel(peer), dstaddr ? socktoa(dstaddr) : "-",
+ ulfptoa(t1, 9), ulfptoa(t2, 9),
+ ulfptoa(t3, 9), ulfptoa(t4, 9),
leap, version, mode, stratum, ppoll, precision,
root_delay, root_dispersion, refid_str(refid, stratum),
outcount);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/842aa4112b4898098ac2c462519dac05cf9333a3
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/842aa4112b4898098ac2c462519dac05cf9333a3
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/20170808/edea6eb5/attachment.html>
More information about the vc
mailing list