From: Harlan Stenn Date: Wed, 5 Oct 2005 07:02:11 +0000 (-0400) Subject: orphan fixes from Dave Mills X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ac416de0f1fe4184d5cb552bcd3fe41a791100b;p=thirdparty%2Fntp.git orphan fixes from Dave Mills bk: 43437a73hU7gEmQxy79Sw6Xum5LkKw --- diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 4daf2efd29..51b1cd9246 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -132,23 +132,25 @@ transmit( * is intricate... */ /* - * In broadcast mode the poll interval is never changed from - * minpoll. Orphan mode is active when enabled and when no other - * source is available. In this mode broadcasts are made at the - * orphan stratum and with root delay randomized over a 1-s - * range. The root delay is used by the election algorithm to - * select a single source from among the orphan dwellers. + * Orphan mode is active when enabled and when no other source + * is available. In this mode packets are sent at the orphan + * stratum and with root delay randomized over a 1-s range. In + * broadcast mode the root delay is used by the election + * algorithm to select a single source from among the orphans. */ hpoll = peer->hpoll; + if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL) { + sys_leap = LEAP_NOWARNING; + sys_stratum = sys_orphan; + } + + /* + * In broadcast mode the poll interval is never changed from + * minpoll. + */ if (peer->cast_flags & (MDF_BCAST | MDF_MCAST)) { peer->outdate = current_time; - if (sys_peer != NULL) { - peer_xmit(peer); - } else if (sys_orphan < STRATUM_UNSPEC) { - sys_leap = LEAP_NOWARNING; - sys_stratum = sys_orphan; - peer_xmit(peer); - } + peer_xmit(peer); poll_update(peer, hpoll); return; } @@ -2167,7 +2169,7 @@ clock_select(void) sys_refid = htonl(LOOPBACKADR); } else { sys_offset = sys_peer->offset; - sys_refid = sys_peer->refid; + sys_refid = addr2refid(&sys_peer->srcadr); } sys_jitter = LOGTOD(sys_precision); #ifdef DEBUG @@ -2219,8 +2221,8 @@ clock_select(void) sys_peer = typesystem; sys_peer->status = CTL_PST_SEL_SYSPEER; clock_combine(peer_list, nlist); - if (sys_stratum == STRATUM_REFCLOCK || sys_stratum == - STRATUM_UNSPEC) + if (sys_peer->stratum == STRATUM_REFCLOCK || + sys_peer->stratum == STRATUM_UNSPEC) sys_refid = sys_peer->refid; else sys_refid = addr2refid(&sys_peer->srcadr);