From: Dave Hart Date: Tue, 29 Nov 2011 21:58:49 +0000 (+0000) Subject: [Bug 2073] Correct ntpq billboard's MODE_PASSIVE t from 'u' to 'S'. X-Git-Tag: NTP_4_2_7P237~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf1d7d4c4aeb55ba901917b6f3672a1505b58fd2;p=thirdparty%2Fntp.git [Bug 2073] Correct ntpq billboard's MODE_PASSIVE t from 'u' to 'S'. Round l_fp traffic interval when converting to integer in rate limit and KoD calculation. bk: 4ed55599H5T9_2tYPc8gsx9VUZ0e4Q --- diff --git a/ChangeLog b/ChangeLog index 9558ab2f9..deda30f59 100644 --- 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 * Documentation updates from Dave Mills. (4.2.7p235) 2011/11/16 Released by Harlan Stenn diff --git a/include/ntp.h b/include/ntp.h index 55fb088ab..bb547aac0 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -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 diff --git a/ntpd/ntp_monitor.c b/ntpd/ntp_monitor.c index 673f62607..5f674e1ac 100644 --- a/ntpd/ntp_monitor.c +++ b/ntpd/ntp_monitor.c @@ -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) */ diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index b8fb6a1c6..5a0dc8db2 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -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 diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 19e496b62..6ddd895af 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -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; diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c index dbaae1586..d11d5db66 100644 --- a/ntpq/ntpq-subs.c +++ b/ntpq/ntpq-subs.c @@ -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 */ } /*