[Git][NTPsec/ntpsec][master] Refactor the logging hooks for peer, loop, and raw stats...
Eric S. Raymond
gitlab at mg.gitlab.com
Thu Jul 7 11:13:40 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
ea3622c3 by Eric S. Raymond at 2016-07-07T07:09:54-04:00
Refactor the logging hooks for peer, loop, and raw stats...
...so they have access to peer->procptr. We'll use this in a later
behavior change.
Logging of peer, loop, clock, and raw statistics works live at this
revision.
- - - - -
3 changed files:
- include/ntpd.h
- ntpd/ntp_proto.c
- ntpd/ntp_util.c
Changes:
=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -248,13 +248,13 @@ extern u_long orphwait; /* orphan wait time */
extern void init_util (void);
extern void write_stats (void);
extern void stats_config (int, const char *);
-extern void record_peer_stats (sockaddr_u *, int, double, double, double, double);
+extern void record_peer_stats (struct peer *, int);
extern void record_proto_stats (char *);
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 (const struct peer *, 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 check_leap_file (int is_daily_check, uint32_t ntptime, const time_t * systime);
extern void record_crypto_stats (sockaddr_u *, const char *);
#ifdef DEBUG
=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -1302,7 +1302,7 @@ process_packet(
/*
* Capture the header values in the client/peer association..
*/
- record_raw_stats(&peer->srcadr, peer->dstadr ?
+ record_raw_stats(peer, &peer->srcadr, peer->dstadr ?
&peer->dstadr->sin : NULL,
&p_org, &p_rec, &p_xmt, &peer->dst,
pleap, pversion, pmode, pstratum, pkt->ppoll, pkt->precision,
@@ -2079,8 +2079,7 @@ clock_filter(
* processing. If not synchronized or not in a burst, tickle the
* clock select algorithm.
*/
- record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
- peer->offset, peer->delay, peer->disp, peer->jitter);
+ record_peer_stats(peer, ctlpeerstatus(peer));
#ifdef DEBUG
if (debug)
printf(
=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -395,12 +395,8 @@ stats_config(
*/
void
record_peer_stats(
- sockaddr_u *addr,
- int status,
- double offset, /* offset */
- double delay, /* delay */
- double dispersion, /* dispersion */
- double jitter /* jitter */
+ struct peer *peer,
+ int status
)
{
l_fp now;
@@ -416,8 +412,8 @@ record_peer_stats(
if (peerstats.fp != NULL) {
fprintf(peerstats.fp,
"%lu %s %s %x %.9f %.9f %.9f %.9f\n", day,
- ulfptoa(&now, 3), stoa(addr), status, offset,
- delay, dispersion, jitter);
+ ulfptoa(&now, 3), stoa(&peer->srcadr), status, peer->offset,
+ peer->delay, peer->disp, peer->jitter);
fflush(peerstats.fp);
}
}
@@ -532,6 +528,7 @@ mprintf_clock_stats(
*/
void
record_raw_stats(
+ const struct peer *peer,
sockaddr_u *srcadr,
sockaddr_u *dstadr,
l_fp *t1, /* originate timestamp */
@@ -554,6 +551,8 @@ record_raw_stats(
l_fp now;
u_long day;
+ UNUSED_ARG(peer);
+
if (!stats_control)
return;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/ea3622c3af604f4d5442971c8d2930fcddc8ff6c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160707/e16752a1/attachment.html>
More information about the vc
mailing list