From: Harlan Stenn Date: Thu, 1 Mar 2001 19:05:10 +0000 (-0000) Subject: ChangeLog, ntp.h, ntp_crypto.c, ntp_proto.c: X-Git-Tag: NTP_4_0_99_M~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efe3d4d6d2f84e21c19b193f36b9a1297237ccd2;p=thirdparty%2Fntp.git ChangeLog, ntp.h, ntp_crypto.c, ntp_proto.c: * ntpd/ntp_proto.c (transmit): hpoll cleanup. Call clock_select() after calling poll_update, not before. (receive): Call poll_update after crypto_recv if FLAG_SKEY. (process_packet): Set peer->ppoll Later. (poll_update): peer->hpoll sanity checking. Set peer->outdate, not ->nextate, when burst > 0. MDF_ACAST cleanup. (clock_select): Fix hpoll typo in call to poll_update(). * ntpd/ntp_crypto.c (crypto_xmit): tstamp's value is a function of PUBKEY. * include/ntp.h (clear_to_zero): #define value is a function of AUTOKEY. From: Dave Mills. bk: 3a9e9d66EvNkWMSLGfpCmnyyYoQgjg --- diff --git a/ChangeLog b/ChangeLog index e0c5cc6695..1dfc2c8fe7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2001-03-01 Harlan Stenn + + * ntpd/ntp_proto.c (transmit): hpoll cleanup. Call clock_select() + after calling poll_update, not before. + (receive): Call poll_update after crypto_recv if FLAG_SKEY. + (process_packet): Set peer->ppoll Later. + (poll_update): peer->hpoll sanity checking. Set peer->outdate, + not ->nextate, when burst > 0. MDF_ACAST cleanup. + (clock_select): Fix hpoll typo in call to poll_update(). + * ntpd/ntp_crypto.c (crypto_xmit): tstamp's value is a function of + PUBKEY. + * include/ntp.h (clear_to_zero): #define value is a function of + AUTOKEY. + From: Dave Mills. + 2001-02-28 Harlan Stenn * ntpd/ntp_proto.c (transmit): Documentation/code update. diff --git a/include/ntp.h b/include/ntp.h index d765e9c321..9abfee3e38 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -267,14 +267,16 @@ struct peer { /* * Variables used by authenticated client */ -#define clear_to_zero assoc #ifdef AUTOKEY +#define clear_to_zero assoc associd_t assoc; /* peer association ID */ u_int32 crypto; /* peer status word */ #ifdef PUBKEY struct value pubkey; /* public key */ u_char *keystr; /* public key file name */ #endif /* PUBKEY */ +#else /* AUTOKEY */ +#define clear_to_zero keyid #endif /* AUTOKEY */ keyid_t keyid; /* current key ID */ keyid_t pkeyid; /* previous key ID */ diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c index 56d0c387c9..a4b00f19b3 100644 --- a/ntpd/ntp_crypto.c +++ b/ntpd/ntp_crypto.c @@ -946,7 +946,11 @@ crypto_xmit( */ case CRYPTO_ASSOC | CRYPTO_RESP: cp = (struct cookie *)&xpkt[i + 2]; +#ifdef PUBKEY cp->tstamp = host.tstamp; +#else + cp->tstamp = 0; +#endif /* PUBKEY */ cp->key = htonl(crypto_flags); cp->siglen = 0; len += 12; diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 2a1ff6a76a..7edc0abfef 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -134,7 +134,7 @@ transmit( else hpoll++; } else { - hpoll = peer->maxpoll; + hpoll = sys_poll; } #endif /* AUTOKEY */ } else { @@ -233,8 +233,8 @@ transmit( key_expire(peer); #endif /* AUTOKEY */ } - clock_select(); poll_update(peer, hpoll); + clock_select(); return; } @@ -776,6 +776,7 @@ receive( if (peer->flags & FLAG_SKEY) { peer->flash |= TEST10; crypto_recv(peer, rbufp); + poll_update(peer, peer->hpoll); if (hismode == MODE_SERVER) { if (skeyid == peer->keyid) peer->flash &= ~TEST10; @@ -881,7 +882,6 @@ process_packet( * Test for old, duplicate or unsynch packets (tests 1-3). */ peer->rec = *recv_ts; - peer->ppoll = pkt->ppoll; pmode = PKT_MODE(pkt->li_vn_mode); pleap = PKT_LEAP(pkt->li_vn_mode); pstratum = PKT_TO_STRATUM(pkt->stratum); @@ -949,6 +949,7 @@ process_packet( peer->leap = pleap; peer->pmode = pmode; peer->stratum = pstratum; + peer->ppoll = pkt->ppoll; peer->precision = pkt->precision; peer->rootdelay = p_del; peer->rootdispersion = p_disp; @@ -1134,12 +1135,14 @@ poll_update( #ifdef AUTOKEY oldpoll = peer->kpoll; #endif /* AUTOKEY */ - if (hpoll > peer->maxpoll) - peer->hpoll = peer->maxpoll; - else if (hpoll < peer->minpoll) - peer->hpoll = peer->minpoll; + if (peer->flags & FLAG_SYSPEER) + peer->hpoll = sys_poll; else peer->hpoll = hpoll; + if (peer->hpoll > peer->maxpoll) + peer->hpoll = peer->maxpoll; + else if (peer->hpoll < peer->minpoll) + peer->hpoll = peer->minpoll; /* * bit of adventure here. If during a burst and not timeout, @@ -1152,7 +1155,7 @@ poll_update( * randomize over the poll interval -1 to +2 seconds. */ if (peer->burst > 0) { - if (peer->nextdate != current_time) + if (peer->outdate != current_time) return; if (peer->flags & FLAG_REFCLOCK) peer->nextdate++; @@ -1160,6 +1163,15 @@ poll_update( peer->nextdate += RANDPOLL(BURST_INTERVAL2); else peer->nextdate += RANDPOLL(BURST_INTERVAL1); +#if 0 /* xxxxx */ + } else if (peer->crypto && (!(peer->flags & FLAG_AUTOKEY) || + peer->cmmd)) { + peer->burst = 1; + peer->nextdate += RANDPOLL(BURST_INTERVAL2); +#endif /* PUBKEY */ + } else if (peer->cast_flags & MDF_ACAST) { + peer->kpoll = peer->hpoll + 3; + peer->nextdate = peer->outdate + RANDPOLL(peer->kpoll); } else { peer->kpoll = max(min(peer->ppoll, peer->hpoll), peer->minpoll); @@ -1796,7 +1808,7 @@ clock_select(void) peer = peer_list[i]; peer->status = CTL_PST_SEL_SYNCCAND; peer->flags |= FLAG_SYSPEER; - poll_update(peer, sys_poll); + poll_update(peer, peer->hpoll); if (peer->stratum == peer_list[0]->stratum) { leap_consensus |= peer->leap; if (peer->refclktype == REFCLK_ATOM_PPS &&