]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
orphanwait changes (Bug 1560) and clockfilter/reachability fixes from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Tue, 15 Jun 2010 04:24:37 +0000 (00:24 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 15 Jun 2010 04:24:37 +0000 (00:24 -0400)
bk: 4c170085pdkdubBIgwio_jn_HobUsQ

ChangeLog
include/ntp.h
include/ntpd.h
ntpd/ntp_proto.c
ntpd/ntp_timer.c

index 4d4f7e957d4cbc233d16f0c0bb6de07aa436fd9c..4b8e20e9c12f568f6b2359abc02c010e314c1497 100644 (file)
--- 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 <stenn@ntp.org>
 * Rewrite of multiprecision macros in 'ntp_fp.h' from J. Perlinger
   <perlinger@ntp.org>
index 8f9b39fa9badfdffa9185d91c603d98d7bff7548..5d6ac934ea8c7f06b98a767cad129aa67b2cf7c6 100644 (file)
@@ -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
index 01a4178f659919a490d7b8becc37cefae8275a4f..7b0b2e94a564377de0c72ac356730018aa49ffd2 100644 (file)
@@ -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 */
index 556cd8e51f83b0e7a3a5a2486d7f7ac5c24011c3..65c00430b1dd99590eac115f763dc925cab8292d 100644 (file)
@@ -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;
index bc12b412997b60fb628f107a404eac41e4645438..9037d90e5c23aa86302d95e70de7edd70e8aa072 100644 (file)
@@ -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