From: Dave Hart Date: Sat, 13 Apr 2024 18:47:27 +0000 (+0000) Subject: [Bug 3914] Spurious "Unexpected origin timestamp" logged after time stepped. X-Git-Tag: NTP_4_2_8P18_RC1~9^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4210ad20e958a90bd2b26a41767ffff2cac17e0;p=thirdparty%2Fntp.git [Bug 3914] Spurious "Unexpected origin timestamp" logged after time stepped. bk: 661ad33fhJ_4wZSFex2jIqpcNE64_w --- diff --git a/ChangeLog b/ChangeLog index c5d0f5a49..401140f76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --- +* [Bug 3914] Spurious "Unexpected origin timestamp" logged after time + stepped. * [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe. * [Bug 3901] LIB_GETBUF isn't thread-safe. diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 35c9a825f..8c5e7ccf5 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -592,6 +592,7 @@ transmit( } +#ifdef DEBUG const char * amtoa( int am @@ -615,6 +616,7 @@ amtoa( return bp; } } +#endif /* DEBUG */ /* @@ -634,7 +636,6 @@ receive( r4addr r4a; /* address restrictions */ u_short restrict_mask; /* restrict bits */ const char *hm_str; /* hismode string */ - const char *am_str; /* association match string */ int kissCode = NOKISS; /* Kiss Code */ int has_mac; /* length of MAC field */ int authlen; /* offset of MAC field */ @@ -650,6 +651,9 @@ receive( l_fp p_org; /* origin timestamp */ l_fp p_rec; /* receive timestamp */ l_fp p_xmt; /* transmit timestamp */ +#ifdef DEBUG + const char *am_str; /* association match string */ +#endif #ifdef AUTOKEY char hostname[NTP_MAXSTRLEN + 1]; char *groupname = NULL; @@ -995,7 +999,9 @@ receive( NTOHL_FP(&pkt->rec, &p_rec); NTOHL_FP(&pkt->xmt, &p_xmt); hm_str = modetoa(hismode); +#ifdef DEBUG am_str = amtoa(retcode); +#endif /* * Authentication is conditioned by three switches: @@ -2050,13 +2056,19 @@ receive( /* XXX: FLAG_LOOPNONCE */ DEBUG_INSIST(0 == (FLAG_LOOPNONCE & peer->flags)); - msyslog(LOG_INFO, - "receive: Got KoD %s from %s", - refid_str(pkt->refid, -1), ntoa(&peer->srcadr)); + if (RATEKISS == kissCode) { + msyslog(LOG_INFO, "RATE KoD from %s poll %u", + ntoa(&peer->srcadr), 1u << pkt->ppoll); + } else { + msyslog(LOG_INFO, "KoD %s from %s", + refid_str(pkt->refid, -1), + ntoa(&peer->srcadr)); + } } else if (peer->flip == 0) { if (0) { - } else if (L_ISZERO(&p_org)) { - const char *action; + } + else if (L_ISZERO(&p_org)) { + const char* action; #ifdef BUG3361 msyslog(LOG_INFO, @@ -2066,22 +2078,22 @@ receive( #endif /**/ switch (hismode) { - /* We allow 0org for: */ - case UCHAR_MAX: + /* We allow 0org for: */ + case UCHAR_MAX: action = "Allow"; break; - /* We disallow 0org for: */ - case MODE_UNSPEC: - case MODE_ACTIVE: - case MODE_PASSIVE: - case MODE_CLIENT: - case MODE_SERVER: - case MODE_BROADCAST: + /* We disallow 0org for: */ + case MODE_UNSPEC: + case MODE_ACTIVE: + case MODE_PASSIVE: + case MODE_CLIENT: + case MODE_SERVER: + case MODE_BROADCAST: action = "Drop"; peer->bogusorg++; peer->flash |= TEST2; /* bogus */ break; - default: + default: action = ""; /* for cranky compilers / MSVC */ INSIST(!"receive(): impossible hismode"); break; @@ -2091,17 +2103,19 @@ receive( "receive: %s 0 origin timestamp from %s@%s xmt 0x%x.%08x", action, hm_str, ntoa(&peer->srcadr), ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)); + } else if ( L_ISZERO(&peer->aorg) && MODE_CLIENT != hismode + && !memcmp("STEP", &peer->refid, 4)) { + /* response came in just after we stepped clock, normal */ } else if (!L_ISEQU(&p_org, &peer->aorg)) { /* are there cases here where we should bail? */ /* Should we set TEST2 if we decide to try xleave? */ peer->bogusorg++; peer->flash |= TEST2; /* bogus */ - msyslog(LOG_INFO, - "receive: Unexpected origin timestamp 0x%x.%08x does not match aorg 0x%x.%08x from %s@%s xmt 0x%x.%08x", + msyslog(LOG_INFO, + "duplicate or replay: org 0x%x.%08x does not match 0x%x.%08x from %s@%s", ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf), peer->aorg.l_ui, peer->aorg.l_uf, - hm_str, ntoa(&peer->srcadr), - ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)); + hm_str, ntoa(&peer->srcadr)); if ( !L_ISZERO(&peer->dst) && L_ISEQU(&p_org, &peer->dst)) { /* Might be the start of an interleave */