From: Harlan Stenn Date: Sat, 13 Jul 2002 01:37:25 +0000 (-0400) Subject: Merge Dave's changes into ipV6. X-Git-Tag: NTP_4_1_73~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d8e73cb5f447ec4047664c49fdacfffa2ea5a24;p=thirdparty%2Fntp.git Merge Dave's changes into ipV6. bk: 3d2f8455IYPT4jyI4qbwurzYb6dUMw --- 2d8e73cb5f447ec4047664c49fdacfffa2ea5a24 diff --cc ntpd/ntp_proto.c index d32520dc76,a98573552e..9c5cd72655 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@@ -169,90 -180,101 +181,101 @@@ transmit return; } } - oreach = peer->reach; - peer->reach <<= 1; - peer->hyst *= HYST_TC; - if (peer->reach == 0) { + if (peer->burst == 0) { + u_char oreach; - /* - * If this association has become unreachable, - * clear it and raise a trap. - */ - if (oreach != 0) { - report_event(EVNT_UNREACH, peer); - peer->timereachable = current_time; - if (peer->flags & FLAG_CONFIG) { - peer_clear(peer, "IDLE"); - } else { - unpeer(peer); - return; + oreach = peer->reach; + peer->reach <<= 1; + peer->hyst *= HYST_TC; + if (peer->reach == 0) { + + /* + * If this association has become + * unreachable, clear it and raise a + * trap. + */ + if (oreach != 0) { + report_event(EVNT_UNREACH, + peer); + peer->timereachable = + current_time; + if (peer->flags & FLAG_CONFIG) { + peer_clear(peer, + "INIT"); + } else { + unpeer(peer); + return; + } + } + if (peer->flags & FLAG_IBURST) + peer->burst = NTP_BURST; + } else { - + /* + * Here the peer is reachable. If it has + * not been heard for three consecutive + * polls, stuff the clock filter. Next, + * determine the poll interval. If the + * peer is a synchronization candidate, + * use the system poll interval. If we + * cannot synchronize to the peer + * increase it by one. + */ + if (!(peer->reach & 0x07)) { + clock_filter(peer, 0., 0., + MAXDISPERSE); + clock_select(); + } - if ((peer->stratum > 1 && peer->refid == - peer->dstadr->sin.sin_addr.s_addr) - || peer->stratum == STRATUM_UNSPEC) ++ if ((peer->stratum > 1 && ++ peer->dstadr->sin.ss_family == AF_INET ? ++ peer->refid == GET_INADDR(peer->dstadr->sin) : ++ peer->refid == host_refid) || ++ peer->stratum == STRATUM_UNSPEC) + hpoll++; + else + hpoll = sys_poll; + if (peer->flags & FLAG_BURST) + peer->burst = NTP_BURST; } - } - if (peer->flags & FLAG_IBURST) - peer->burst = NTP_BURST; } else { - - /* - * Here the peer is reachable. If it has not - * been heard for three consecutive polls, stuff - * the clock filter. Next, determine the poll - * interval. If the peer is a synchronization - * candidate, use the system poll interval. If - * we cannot synchronize to the peer increase it - * by one. - */ - if (!(peer->reach & 0x07)) { - clock_filter(peer, 0., 0., MAXDISPERSE); - clock_select(); - } - if ((peer->stratum > 1 && - peer->dstadr->sin.ss_family == AF_INET ? - peer->refid == GET_INADDR(peer->dstadr->sin) : - peer->refid == host_refid) || - peer->stratum == STRATUM_UNSPEC) - hpoll++; - else - hpoll = sys_poll; - if (peer->flags & FLAG_BURST) - peer->burst = NTP_BURST; - } - } else { - peer->burst--; - if (peer->burst == 0) { - - /* - * If a broadcast client at this point, the - * burst has concluded, so we switch to client - * mode and purge the keylist, since no further - * transmissions will be made. - */ - if (peer->cast_flags & MDF_BCLNT) { - peer->hmode = MODE_BCLIENT; + peer->burst--; + if (peer->burst == 0) { - + /* + * If a broadcast client at this point, + * the burst has concluded, so we switch + * to client mode and purge the keylist, + * since no further transmissions will + * be made. + */ + if (peer->cast_flags & MDF_BCLNT) { + peer->hmode = MODE_BCLIENT; #ifdef OPENSSL - key_expire(peer); + key_expire(peer); #endif /* OPENSSL */ - } - poll_update(peer, hpoll); - clock_select(); + } + poll_update(peer, hpoll); + clock_select(); - /* - * If ntpdate mode and the clock has not been - * set and all peers have completed the burst, - * we declare a successful failure. - */ - if (mode_ntpdate) { - peer_ntpdate--; - if (peer_ntpdate > 0) - return; - NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT) - msyslog(LOG_NOTICE, - "no reply; clock not set"); - printf( - "ntpd: no reply; clock not set\n"); - exit(0); + /* + * If ntpdate mode and the clock has not + * been set and all peers have completed + * the burst, we declare a successful + * failure. + */ + if (mode_ntpdate) { + peer_ntpdate--; + if (peer_ntpdate > 0) + return; + + NLOG(NLOG_SYNCEVENT | + NLOG_SYSEVENT) + msyslog(LOG_NOTICE, + "no reply; clock not set"); + printf( + "ntpd: no reply; clock not set\n"); + exit(0); + } + return; } - return; - } } peer->outdate = current_time; @@@ -725,16 -745,11 +746,19 @@@ receive if (crypto_flags) { if ((rval = crypto_recv(peer, rbufp)) != XEVNT_OK) { + struct sockaddr_in mskadr_sin; + unpeer(peer); + sys_restricted++; - mskadr_sin.sin_addr.s_addr = 0xffffffff; + memset((char *)&mskadr_sin, 0, + sizeof(struct sockaddr_storage)); + mskadr_sin.ss_family = + rbufp->recv_srcadr.ss_family; + if (mskadr_sin.ss_family == AF_INET) + GET_INADDR(mskadr_sin) = 0xffffffff; + else + memset(&GET_INADDR6(mskadr_sin), 0xff, + sizeof(struct in6_addr)); hack_restrict(RESTRICT_FLAGS, &rbufp->recv_srcadr, &mskadr_sin, 0, RES_DONTTRUST | RES_TIMEOUT); @@@ -1347,13 -1307,10 +1316,11 @@@ clock_update(void */ default: sys_stratum = sys_peer->stratum + 1; - if (sys_stratum == 1) + if (sys_stratum == 1 || sys_stratum == STRATUM_UNSPEC) sys_refid = sys_peer->refid; - else if (sys_stratum == STRATUM_UNSPEC) - memcpy(&sys_refid, "UNSP", 4); else - sys_refid = sys_peer->srcadr.sin_addr.s_addr; + sys_refid = sys_peer->srcadr.ss_family == AF_INET ? + GET_INADDR(sys_peer->srcadr) : host_refid; sys_reftime = sys_peer->rec; sys_rootdelay = sys_peer->rootdelay + sys_peer->delay; sys_leap = leap_consensus;