<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>
Eric S. Raymond pushed to branch master
at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b">77337b66</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-22T07:03:20Z</i>
</div>
<pre class='commit-message'>This revision *almost* successfully round-trips a receive in replay.

Something unfortunate going oin with low-order bts in a timestamp.</pre>
</li>
</ul>
<h4>4 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
ntpd/ntp_intercept.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
ntpd/ntp_io.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
ntpd/ntp_proto.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-3'>
ntpd/ntp_timer.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b#diff-0'>
<strong>
ntpd/ntp_intercept.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_intercept.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_intercept.c
</span><span style="color: #aaaaaa">@@ -645,17 +645,18 @@ static void packet_dump(char *buf, size_t buflen,
</span> static void packet_parse(char *pktbuf, char *macbuf, struct pkt *pkt)
 {
     char refbuf[32], orgbuf[32], recbuf[32], xmtbuf[32];
<span style="color: #000000;background-color: #ffdddd">-    int li_vn_mode = 0, stratum = 0, ppoll = 0, precision = 0;
-
-    if (sscanf(pktbuf, "%d:%d:%d:%d:%u:%u:%u:%s:%s:%s:%s",
-              &li_vn_mode, &stratum,
-              &ppoll, &precision,
-              &pkt->rootdelay, &pkt->rootdisp,
-              &pkt->refid,
-              refbuf, orgbuf, recbuf, xmtbuf) != 7)
</span><span style="color: #000000;background-color: #ddffdd">+    int fc, li_vn_mode = 0, stratum = 0, ppoll = 0, precision = 0;
+
+    printf("Foo! %s\n", pktbuf);
+    if ((fc = sscanf(pktbuf, "%d:%d:%d:%d:%u:%u:%u:%[^:]:%[^:]:%[^:]:%[^:]",
+                    &li_vn_mode, &stratum,
+                    &ppoll, &precision,
+                    &pkt->rootdelay, &pkt->rootdisp,
+                    &pkt->refid,
+                    refbuf, orgbuf, recbuf, xmtbuf)) != 11)
</span>     {
<span style="color: #000000;background-color: #ffdddd">-        fprintf(stderr, "ntpd: malformed packet dump at line %d\n",
-               lineno);
</span><span style="color: #000000;background-color: #ddffdd">+   fprintf(stderr, "ntpd: %d fields in malformed packet dump at line %d\n",
+               fc, lineno);
</span>   exit(1);
     }
     /* extra transfers required because the struct members are int8_t */
<span style="color: #aaaaaa">@@ -731,6 +732,11 @@ void intercept_receive(struct recvbuf *rbufp)
</span>   fputs(pkt_dump, stdout);
     }
 
<span style="color: #000000;background-color: #ddffdd">+    /*
+     * Processing has to come after the dump so that if a send or time adjustment
+     * is called during replay the corresponding event in the log will be found
+     * where it should be after the receive.
+     */
</span>     receive(rbufp);
 }
 
<span style="color: #aaaaaa">@@ -739,9 +745,9 @@ void intercept_replay(void)
</span>     printf("# entering replay loop at line %d\n", lineno);
     for (;;) {
        get_operation(NULL);
<span style="color: #000000;background-color: #ffdddd">-        if (strncmp(linebuf, "finish", 6) == 0)
</span><span style="color: #000000;background-color: #ddffdd">+   if (strncmp(linebuf, "finish", 7) == 0)
</span>       break;
<span style="color: #000000;background-color: #ffdddd">-        else if (strncmp(linebuf, "sendpkt ", 9) == 0)
</span><span style="color: #000000;background-color: #ddffdd">+   else if (strncmp(linebuf, "sendpkt ", 8) == 0)
</span>       /*
             * 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,
<span style="color: #aaaaaa">@@ -768,7 +774,7 @@ void intercept_replay(void)
</span>       }
 
            pkt = &rbuf.recv_pkt;
<span style="color: #000000;background-color: #ffdddd">-            packet_parse(recvbuf, macbuf, pkt);
</span><span style="color: #000000;background-color: #ddffdd">+       packet_parse(pktbuf, macbuf, pkt);
</span> 
            /*
             * If the packet doesn't dump identically to how it came in,
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b#diff-1'>
<strong>
ntpd/ntp_io.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_io.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_io.c
</span><span style="color: #aaaaaa">@@ -3395,7 +3395,11 @@ fetch_timestamp(
</span>                           break;
 #endif  /* USE_SCM_TIMESTAMP */
                        }
<span style="color: #000000;background-color: #ffdddd">-                        fuzz = intercept_ntp_random(__func__) * 2. / FRAC * sys_fuzz;
</span><span style="color: #000000;background-color: #ddffdd">+                   /*
+                        * RNG call does notb have toi be recorded for replay
+                        * because the fuzzed timestamp is recorded.
+                        */
+                       fuzz = ntp_random() * 2. / FRAC * sys_fuzz;
</span>                   DTOLFP(fuzz, &lfpfuzz);
                        L_ADD(&nts, &lfpfuzz);
 #ifdef DEBUG_TIMING
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b#diff-2'>
<strong>
ntpd/ntp_proto.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_proto.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_proto.c
</span><span style="color: #aaaaaa">@@ -2024,12 +2024,12 @@ clock_update(
</span>           if (leapsec == LSPROX_NOWARN) {
                        if (leap_vote_ins > leap_vote_del
                            && leap_vote_ins > sys_survivors / 2) {
<span style="color: #000000;background-color: #ffdddd">-                                intercept_get_systime(__func__, &now);
</span><span style="color: #000000;background-color: #ddffdd">+                           get_systime(&now);
</span>                           leapsec_add_dyn(true, now.l_ui, NULL);
                        }
                        if (leap_vote_del > leap_vote_ins
                            && leap_vote_del > sys_survivors / 2) {
<span style="color: #000000;background-color: #ffdddd">-                                intercept_get_systime(__func__, &now);
</span><span style="color: #000000;background-color: #ddffdd">+                           get_systime(&now);
</span>                           leapsec_add_dyn(false, now.l_ui, NULL);
                        }
                }
<span style="color: #aaaaaa">@@ -2142,7 +2142,11 @@ poll_update(
</span>                   next = 1 << hpoll;
                else
 #endif /* REFCLOCK */
<span style="color: #000000;background-color: #ffdddd">-                        next = ((0x1000UL | (intercept_ntp_random(__func__) & 0x0ff)) <<
</span><span style="color: #000000;background-color: #ddffdd">+                   /*
+                        * Doesn't need to be captured, because the poll interval
+                        * has no effect on replay.
+                        */
+                       next = ((0x1000UL | (ntp_random() & 0x0ff)) <<
</span>                       hpoll) >> 12;
                next += peer->outdate;
                if (next > utemp)
<span style="color: #aaaaaa">@@ -3106,7 +3110,7 @@ peer_xmit(
</span>            * Transmit a-priori timestamps.  This is paired with
                 * a later call used to record transmission time.
                 */
<span style="color: #000000;background-color: #ffdddd">-                intercept_get_systime("pre-sendpkt", &xmt_tx);
</span><span style="color: #000000;background-color: #ddffdd">+           get_systime(&xmt_tx);
</span>           if (peer->flip == 0) {       /* basic mode */
                        peer->aorg = xmt_tx;
                        HTONL_FP(&xmt_tx, &xpkt.xmt);
<span style="color: #aaaaaa">@@ -3137,7 +3141,7 @@ peer_xmit(
</span>           /*
                 * Capture a-posteriori timestamps
                 */
<span style="color: #000000;background-color: #ffdddd">-                intercept_get_systime("post-sendpkt", &xmt_ty);
</span><span style="color: #000000;background-color: #ddffdd">+           get_systime(&xmt_ty);
</span>           if (peer->flip != 0) {               /* interleaved modes */
                        if (peer->flip > 0)
                                peer->aorg = xmt_ty;
</code></pre>

<br>
</li>
<li id='diff-3'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b#diff-3'>
<strong>
ntpd/ntp_timer.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_timer.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_timer.c
</span><span style="color: #aaaaaa">@@ -331,10 +331,7 @@ timer(void)
</span>           sys_rootdisp = 0;
        }
 
<span style="color: #000000;background-color: #ffdddd">-        /*
-        * Recorded and played back in case the leap-second check fires.
-        */
-       intercept_get_systime(__func__, &now);
</span><span style="color: #000000;background-color: #ddffdd">+   get_systime(&now);
</span>   time(&tnow);
 
        /*
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/77337b663d95d3d756ca4e00feb0b920c7e0ad8b"}}</script>
</p>
</div>
</body>
</html>