]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3644] Unsynchronized server (minsane not satisfied) selected as candidate
authorJuergen Perlinger <perlinger@ntp.org>
Sun, 31 May 2020 09:13:45 +0000 (11:13 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sun, 31 May 2020 09:13:45 +0000 (11:13 +0200)
bk: 5ed37549ehF1pCNIS3ebj4MQteJUwQ

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

index 5cd7735314741c48ef798c8438c7c497a8bb8613..9ae09a309ad8b168fcb5cdf17f9d5dc268a0b7e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+---
+* [Bug 3644] Unsynchronized server [...] selected as candidate <perlinger@ntp.org>
+
 ---
 (4.2.8p15) 2020/04/xx Released by Harlan Stenn <stenn@ntp.or>
 
index 97f0d5f9e2de27ef6994077fd08a85bd61efb70c..8e0ea2b202a79435a633aa09ada02e4a72f5373c 100644 (file)
@@ -128,7 +128,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) */
+#define        NTP_ORPHWAIT    300     /* orphan wait (s) */
 
 /*
  * Miscellaneous stuff
index a7543f78b906db6feeccb99959adc3b3eb609ea8..352882b970596849aa4873b5beb46c15d2320e80 100644 (file)
@@ -3972,8 +3972,7 @@ clock_select(void)
         */
        if (typesystem == NULL) {
                if (osys_peer != NULL) {
-                       if (sys_orphwait > 0)
-                               orphwait = current_time + sys_orphwait;
+                       orphwait = current_time + sys_orphwait;
                        report_event(EVNT_NOPEER, NULL, NULL);
                }
                sys_peer = NULL;
@@ -5367,7 +5366,7 @@ proto_config(
 
        case PROTO_ORPHWAIT:    /* orphan wait (orphwait) */
                orphwait -= sys_orphwait;
-               sys_orphwait = (int)dvalue;
+               sys_orphwait = (dvalue >= 1) ? (int)dvalue : NTP_ORPHWAIT;
                orphwait += sys_orphwait;
                break;
 
index 9725b5bda3120d81e1f16e65d2c7f4b007fbae24..42088e16e6e3cb574801244c15768bacb27282b4 100644 (file)
@@ -350,21 +350,36 @@ timer(void)
         * than the orphan stratum are available. A server with no other
         * synchronization source is an orphan. It shows offset zero and
         * reference ID the loopback address.
+        *
+        * [bug 3644] If the orphan stratum is >= STRATUM_UNSPEC, we
+        * have to do it a bit different. 'clock_select()' simply
+        * tiptoed home, but since we're unsync'd and have no peer, we
+        * should eventually declare we're out of sync. Otherwise we
+        * would persistently claim we're good, and we're everything but
+        * that...
         */
-       if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL &&
-           current_time > orphwait) {
-               if (sys_leap == LEAP_NOTINSYNC) {
-                       set_sys_leap(LEAP_NOWARNING);
+       if (sys_peer == NULL && current_time > orphwait) {
+               if (sys_orphan < STRATUM_UNSPEC) {
+                       if (sys_leap == LEAP_NOTINSYNC) {
+                               set_sys_leap(LEAP_NOWARNING);
 #ifdef AUTOKEY
-                       if (crypto_flags)
-                               crypto_update();
+                               if (crypto_flags)
+                                       crypto_update();
 #endif /* AUTOKEY */
+                       }
+                       sys_stratum = (u_char)sys_orphan;
+               } else {
+                       if (sys_leap != LEAP_NOTINSYNC) {
+                               set_sys_leap(LEAP_NOTINSYNC);
+                               msyslog(LOG_WARNING, "%s",
+                                       "no peer for too long, server running free now");
+                       }
+                       sys_stratum = STRATUM_UNSPEC;
                }
-               sys_stratum = (u_char)sys_orphan;
                if (sys_stratum > 1)
-                       sys_refid = htonl(LOOPBACKADR);
+                   sys_refid = htonl(LOOPBACKADR);
                else
-                       memcpy(&sys_refid, "LOOP", 4);
+                   memcpy(&sys_refid, "LOOP", 4);
                sys_offset = 0;
                sys_rootdelay = 0;
                sys_rootdisp = 0;