From: Harlan Stenn Date: Tue, 15 Jun 2010 04:24:37 +0000 (-0400) Subject: orphanwait changes (Bug 1560) and clockfilter/reachability fixes from Dave Mills X-Git-Tag: NTP_4_2_7P36~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b13e7e38129b62116d92256e98cc53381e9bda2;p=thirdparty%2Fntp.git orphanwait changes (Bug 1560) and clockfilter/reachability fixes from Dave Mills bk: 4c170085pdkdubBIgwio_jn_HobUsQ --- diff --git a/ChangeLog b/ChangeLog index 4d4f7e957..4b8e20e9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [Bug 1560] Initial support for orphanwait, from Dave Mills. +* clock_filter()/reachability fixes from Dave Mills. (4.2.7p35) 2010/06/12 Released by Harlan Stenn * Rewrite of multiprecision macros in 'ntp_fp.h' from J. Perlinger diff --git a/include/ntp.h b/include/ntp.h index 8f9b39fa9..5d6ac934e 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -137,6 +137,7 @@ typedef char s_char; #define MAX_TTL 8 /* max ttl mapping vector size */ #define BEACON 7200 /* manycast beacon interval */ #define NTP_MAXEXTEN 2048 /* max extension field size */ +#define NTP_ORPHWAIT 300 /* orphan wair (s) */ /* * Miscellaneous stuff @@ -700,6 +701,7 @@ struct pkt { #define PROTO_MAXHOP 24 #define PROTO_BEACON 25 #define PROTO_ORPHAN 26 +#define PROTO_ORPHWAIT 27 /* * Configuration items for the loop filter diff --git a/include/ntpd.h b/include/ntpd.h index 01a4178f6..7b0b2e94a 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -277,6 +277,7 @@ extern void timer_clr_stats (void); extern void timer_interfacetimeout (u_long); extern volatile int interface_interval; extern u_long worker_idle_timer; /* next check current_time */ +extern u_long orphwait; /* orphan wait time */ #ifdef OPENSSL extern char *sys_hostname; /* host name */ extern char *sys_groupname; /* group name */ diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 556cd8e51..65c00430b 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -100,6 +100,7 @@ int sys_minclock = NTP_MINCLOCK; /* minimum candidates */ int sys_maxclock = NTP_MAXCLOCK; /* maximum candidates */ int sys_cohort = 0; /* cohort switch */ int sys_orphan = STRATUM_UNSPEC + 1; /* orphan stratum */ +int sys_orphwait = NTP_ORPHWAIT; /* orphan wait */ int sys_beacon = BEACON; /* manycast beacon interval */ int sys_ttlmax; /* max ttl mapping vector index */ u_char sys_ttl[MAX_TTL]; /* ttl mapping vector */ @@ -233,8 +234,6 @@ transmit( peer->outdate = current_time; peer->unreach++; peer->reach <<= 1; - if (!(peer->reach & 0x0f)) - clock_filter(peer, 0., 0., MAXDISPERSE); if (!peer->reach) { /* @@ -242,8 +241,11 @@ transmit( * previously reachable raise a trap. Send a * burst if enabled. */ - if (oreach) + clock_filter(peer, 0., 0., MAXDISPERSE); + if (oreach) { + peer_unfit(peer); report_event(PEVNT_UNREACH, peer, NULL); + } if ((peer->flags & FLAG_IBURST) && peer->retry == 0) peer->retry = NTP_RETRY; @@ -2116,8 +2118,7 @@ clock_filter( } /* - * If the clock discipline has stabilized, sort the samples by - * distance. + * If and the clock is synchronized,sort the samples by distance. */ if (sys_leap != LEAP_NOTINSYNC) { for (i = 1; i < NTP_SHIFT; i++) { @@ -2746,8 +2747,10 @@ clock_select(void) * current statistics, but do not update the clock. */ if (typesystem == NULL) { - if (osys_peer != NULL) + if (osys_peer != NULL) { + orphwait = current_time + sys_orphwait; report_event(EVNT_NOPEER, NULL, NULL); + } sys_peer = NULL; return; } @@ -3696,6 +3699,7 @@ init_proto(void) sys_bdelay = 0; sys_authenticate = 1; sys_stattime = current_time; + orphwait = current_time + sys_orphwait; proto_clr_stats(); for (i = 0; i < MAX_TTL; i++) { sys_ttl[i] = (u_char)((i * 256) / MAX_TTL); @@ -3819,6 +3823,10 @@ proto_config( sys_orphan = (int)dvalue; break; + case PROTO_ORPHWAIT: /* orphan wait (orphwait) */ + sys_orphwait = (int)dvalue; + break; + case PROTO_ADJ: /* tick increment (tick) */ sys_tick = dvalue; break; diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c index bc12b4129..9037d90e5 100644 --- a/ntpd/ntp_timer.c +++ b/ntpd/ntp_timer.c @@ -65,6 +65,7 @@ static u_long stats_timer; /* stats timer */ static u_long huffpuff_timer; /* huff-n'-puff timer */ u_long leapsec; /* leapseconds countdown */ u_long worker_idle_timer; /* next check for idle intres */ +u_long orphwait; /* orphan wait time */ #ifdef OPENSSL static u_long revoke_timer; /* keys revoke timer */ static u_long keys_timer; /* session key timer */ @@ -303,7 +304,8 @@ timer(void) * synchronization source is an orphan It shows offset zero and * reference ID the loopback address. */ - if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL) { + if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL && + current_time > orphwait) { if (sys_leap == LEAP_NOTINSYNC) { sys_leap = LEAP_NOWARNING; #ifdef OPENSSL