[Git][NTPsec/ntpsec][master] Checkpoint: tweak the capture logging.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Dec 19 10:46:18 UTC 2015


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


Commits:
9d0fd001 by Eric S. Raymond at 2015-12-19T05:45:06Z
Checkpoint:  tweak the capture logging.

- - - - -


4 changed files:

- ntpd/ntp_intercept.c
- ntpd/ntp_io.c
- ntpd/ntp_proto.c
- ntpd/ntp_timer.c


Changes:

=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -741,25 +741,13 @@ void intercept_replay(void)
 	get_operation(NULL);
 	if (strncmp(linebuf, "finish", 6) == 0)
 	    break;
-#if 0
 	else if (strncmp(linebuf, "sendpkt ", 9) == 0)
-	{
-	    struct pkt pkt;
-	    char legend[BUFSIZ], recvbuf[BUFSIZ], destbuf[BUFSIZ];
-	    char pktbuf[BUFSIZ], macbuf[BUFSIZ];
-
-	    if (sscanf(linebuf, "sendpkt %x %s %s %s %s",
-		       legend, recvbuf, destbuf, pktbuf, macbuf) != 5)
-	    {
-		fprintf(stderr, "ntpd: bad receive format at line %d\n", lineno);
-		exit(1);
-	    }
-
-	    packet_parse(recvbuf, macbuf, &pkt);
-
-
-	}
-#endif
+	    /*
+	     * If we get here, this is a sendpkt generated not by the protocol
+	     * machine but by an initial association setup. No way to check it,
+	     * so skip it.
+	     */
+	    continue;
 	else if (strncmp(linebuf, "receive ", 8) == 0)
 	{
 	    struct recvbuf rbuf;


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3804,11 +3804,12 @@ input_handler(
 	}
 	/* We've done our work */
 #ifdef DEBUG_TIMING
-	intercept_get_systime(__func__, &ts_e);
+	get_systime(&ts_e);
 	/*
 	 * (ts_e - ts) is the amount of time we spent
 	 * processing this gob of file descriptors.  Log
-	 * it.
+	 * it.  Because it's only used for logging, this
+	 * get_systime doesn't have to be captured/replayed.
 	 */
 	L_SUB(&ts_e, &ts);
 	collect_timing(NULL, "input handler", 1, &ts_e);


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -3103,11 +3103,10 @@ peer_xmit(
 #endif	/* !ENABLE_AUTOKEY */
 
 		/*
-		 * Transmit a-priori timestamps.  We don't need to log these
-		 * for replay because the timestamp gets stuffed in the packet
-		 * which is what's visible in the replay log.
+		 * Transmit a-priori timestamps.  This is paired with
+		 * a later call used to record transmission time.
 		 */
-		get_systime(&xmt_tx);
+		intercept_get_systime("pre-sendpkt", &xmt_tx);
 		if (peer->flip == 0) {	/* basic mode */
 			peer->aorg = xmt_tx;
 			HTONL_FP(&xmt_tx, &xpkt.xmt);
@@ -3138,7 +3137,7 @@ peer_xmit(
 		/*
 		 * Capture a-posteriori timestamps
 		 */
-		intercept_get_systime(__func__, &xmt_ty);
+		intercept_get_systime("post-sendpkt", &xmt_ty);
 		if (peer->flip != 0) {		/* interleaved modes */
 			if (peer->flip > 0)
 				peer->aorg = xmt_ty;


=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -331,6 +331,9 @@ timer(void)
 		sys_rootdisp = 0;
 	}
 
+	/*
+	 * Recorded and played back in case the leap-second check fires.
+	 */
 	intercept_get_systime(__func__, &now);
 	time(&tnow);
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/9d0fd001ce7bf70a0de2a220000467a902452421
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151219/3e32ea32/attachment.html>


More information about the vc mailing list