]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2073] Correct ntpq billboard's MODE_PASSIVE t from 'u' to 'S'.
authorDave Hart <hart@ntp.org>
Tue, 29 Nov 2011 21:58:49 +0000 (21:58 +0000)
committerDave Hart <hart@ntp.org>
Tue, 29 Nov 2011 21:58:49 +0000 (21:58 +0000)
Round l_fp traffic interval when converting to integer in rate limit
  and KoD calculation.

bk: 4ed55599H5T9_2tYPc8gsx9VUZ0e4Q

ChangeLog
include/ntp.h
ntpd/ntp_monitor.c
ntpd/ntp_peer.c
ntpd/ntp_proto.c
ntpq/ntpq-subs.c

index 9558ab2f92ed8c1942fb4f93b893a22ffe2fe1cc..deda30f59d9109a787d4807dff005dd84f556717 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,10 +8,13 @@
   duplicate ephemeral associations without broadcastdelay.
 * [Bug 2072] from 4.2.6p5-RC2: Orphan parent selection metric needs
   ntohl().
+* [Bug 2073] Correct ntpq billboard's MODE_PASSIVE t from 'u' to 'S'.
 * from 4.2.6p5-RC2: Exclude not-yet-determined sys_refid from use in
   loopback TEST12 (from Dave Mills).
 * Restore 4.2.6 clock_combine() weighting to ntp-dev, reverting to pre-
-  4.2.7p70 logic and avoiding divide-by-zero (from Dave Mills).
+  4.2.7p70 method while also avoiding divide-by-zero (from Dave Mills).
+* Round l_fp traffic interval when converting to integer in rate limit
+  and KoD calculation.
 (4.2.7p236) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>
 * Documentation updates from Dave Mills.
 (4.2.7p235) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>
index 55fb088ab125b6cc6068862532e2816b152a987d..bb547aac06a4704db350c7822272aeb1eed8918f 100644 (file)
@@ -762,7 +762,7 @@ struct mon_data {
 #define        MDF_POOL        0x08    /* pool client solicitor */
 #define MDF_ACAST      0x10    /* manycast client solicitor */
 #define        MDF_BCLNT       0x20    /* eph. broadcast/multicast client */
-#define MDF_UCLNT      0x40    /* eph. manycast or pool client */
+#define MDF_UCLNT      0x40    /* preemptible manycast or pool client */
 /*
  * In the context of struct peer in ntpd, three of the cast_flags bits
  * represent configured associations which never receive packets, and
index 673f626072c0a6fdf7b57e1bda22405fe2481cd3..5f674e1acd7a16d6a87f66cf2effbb6a2025e223 100644 (file)
@@ -310,6 +310,7 @@ ntp_monitor(
        u_short flags
        )
 {
+       l_fp            interval_fp;
        struct pkt *    pkt;
        mon_entry *     mon;
        mon_entry *     oldest;
@@ -318,7 +319,6 @@ ntp_monitor(
        u_short         restrict_mask;
        u_char          mode;
        u_char          version;
-       l_fp            interval_fp;
        int             interval;
        int             head;           /* headway increment */
        int             leak;           /* new headway */
@@ -345,6 +345,8 @@ ntp_monitor(
        if (mon != NULL) {
                interval_fp = rbufp->recv_time;
                L_SUB(&interval_fp, &mon->last);
+               /* add one-half second to round up */
+               L_ADDUF(&interval_fp, 0x80000000);
                interval = interval_fp.l_i;
                mon->last = rbufp->recv_time;
                NSRCPORT(&mon->rmtadr) = NSRCPORT(&rbufp->recv_srcadr);
@@ -440,6 +442,8 @@ ntp_monitor(
                if (oldest != NULL) {
                        interval_fp = rbufp->recv_time;
                        L_SUB(&interval_fp, &oldest->last);
+                       /* add one-half second to round up */
+                       L_ADDUF(&interval_fp, 0x80000000);
                        oldest_age = interval_fp.l_i;
                }
                /* note -1 is legal for mru_maxage (disables) */
index b8fb6a1c67b0c8451720e60dc2c35694e021400d..5a0dc8db2ff4956972274bb8098bf8944e1d61c9 100644 (file)
@@ -206,6 +206,13 @@ findexistingpeer_addr(
 {
        struct peer *peer;
 
+       DPRINTF(2, ("findexistingpeer_addr(%s, %s, %d, 0x%x)\n",
+               sptoa(addr),
+               (start_peer)
+                   ? sptoa(&start_peer->srcadr)
+                   : "NULL",
+               mode, (u_int)cast_flags));
+
        /*
         * start_peer is included so we can locate instances of the
         * same peer through different interfaces in the hash table.
@@ -222,11 +229,17 @@ findexistingpeer_addr(
                peer = start_peer->adr_link;
        
        while (peer != NULL) {
+               DPRINTF(3, ("%s %s %d %d 0x%x 0x%x ", sptoa(addr),
+                       sptoa(&peer->srcadr), mode, peer->hmode,
+                       (u_int)cast_flags, (u_int)peer->cast_flags));
                if ((-1 == mode || peer->hmode == mode ||
                     ((MDF_BCLNT & peer->cast_flags) &&
                      (MDF_BCLNT & cast_flags))) &&
-                   ADDR_PORT_EQ(addr, &peer->srcadr))
+                   ADDR_PORT_EQ(addr, &peer->srcadr)) {
+                       DPRINTF(3, ("found.\n"));
                        break;
+               }
+               DPRINTF(3, ("\n"));
                peer = peer->adr_link;
        }
 
@@ -788,8 +801,13 @@ newpeer(
         * multicast) and preemptible (manycast and pool) client
         * associations.
         */
-       if (peer != NULL)
+       if (peer != NULL) {
+               DPRINTF(2, ("newpeer(%s) found existing association\n",
+                       (hostname)
+                           ? hostname
+                           : stoa(srcadr)));
                return NULL;
+       }
 
        /*
         * Allocate a new peer structure. Some dirt here, since some of
index 19e496b622f882da455e3b8cd4540139bd1b9d5a..6ddd895afa0b97e4210c6454700bfc8f5d6cff56 100644 (file)
@@ -312,9 +312,10 @@ transmit(
                                peer_ntpdate--;
                                if (peer_ntpdate == 0) {
                                        msyslog(LOG_NOTICE,
-                                           "ntpd: no servers found");
-                                       printf(
                                            "ntpd: no servers found\n");
+                                       if (!msyslog_term)
+                                               printf(
+                                                   "ntpd: no servers found\n");
                                        exit (0);
                                }
                        }
@@ -551,8 +552,10 @@ receive(
                sys_limitrejected++;
                if (!(restrict_mask & RES_KOD) || hismode ==
                    MODE_BROADCAST)
+                       //if (MODE_SERVER == hismode)
+                       //      DPRINTF(1, ("Possibly self-induced rate limiting of MODE_SERVER from %s\n",
+                       //              stoa(&rbufp->recv_srcadr)));
                        return;                 /* rate exceeded */
-
                if (hismode == MODE_CLIENT)
                        fast_xmit(rbufp, MODE_SERVER, skeyid,
                            restrict_mask);
@@ -1079,12 +1082,14 @@ receive(
                }
 
                /*
-                * Do not respond if synchronized and stratum is either
+                * Do not respond if synchronized and if stratum is
                 * below the floor or at or above the ceiling. Note,
                 * this allows an unsynchronized peer to synchronize to
                 * us. It would be very strange if he did and then was
                 * nipped, but that could only happen if we were
-                * operating at the top end of the range.
+                * operating at the top end of the range.  It also means
+                * we will spin an ephemeral association in response to
+                * MODE_ACTIVE KoDs, which will time out eventually.
                 */
                if (hisleap != LEAP_NOTINSYNC && (hisstratum <
                    sys_floor || hisstratum >= sys_ceiling)) {
@@ -1993,7 +1998,7 @@ poll_update(
         * sending in a burst, use the earliest time. When not in a
         * burst but with a reply pending, send at the earliest time
         * unless the next scheduled time has not advanced. This can
-        * only happen if multiple replies are peinding in the same
+        * only happen if multiple replies are pending in the same
         * response interval. Otherwise, send at the later of the next
         * scheduled time and the earliest time.
         *
@@ -2466,8 +2471,7 @@ clock_select(void)
 
                        localmet = ntohl(peer->dstadr->addr_refid);
                        peermet = ntohl(addr2refid(&peer->srcadr));
-                       if (peermet < orphmet &&
-                           (current_time <= orphwait || peermet < localmet)) {
+                       if (peermet < localmet && peermet < orphmet) {
                                typeorphan = peer;
                                orphmet = peermet;
                        }
@@ -2915,8 +2919,6 @@ clock_combine(
        y = z = w = 0;
        for (i = 0; i < npeers; i++) {
                d = root_distance(peers[i]);
-               if (0. == d)
-                       d = 1e-6;       /* hart avoid div by 0 */
                x = 1. / d;
                y += x;
                z += peers[i]->offset * x;
index dbaae158620c24efb93609e7c85acd72e056d9d4..d11d5db666931801182c0bf10eb1af462868a1b8 100644 (file)
@@ -1730,8 +1730,12 @@ doprintpeers(
                break;
 
        case MODE_ACTIVE:
-               type = 's';             /* symmetric */
-               break;
+               type = 's';             /* symmetric active */
+               break;                  /* configured */
+
+       case MODE_PASSIVE:
+               type = 'S';             /* symmetric passive */
+               break;                  /* ephemeral */
        }
 
        /*