From: Brian Utterback Date: Wed, 13 Aug 2003 13:46:24 +0000 (-0400) Subject: ignore: X-Git-Tag: NTP_4_2_0~14^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ea2bdbbda706ea7de8a3b88fb69fab4af2e7e6e;p=thirdparty%2Fntp.git ignore: Added firefly.sh include/ntp.patch include/ntp_control.patch include/ntp_request.patch jedi.sh ntpd/ntp_control.patch ntpd/ntp_peer.patch ntpd/ntp_proto.patch ntpd/ntp_request.patch ntpq/ntpq.patch to the ignore list ntp_proto.c, ntp_peer.c, ntp_control.c, ntp_control.h, ntp.h: Add rank counter for each peer. This is incremented each time a peer reaches candidate status, or is actually selected as the system peer. By this method, peers that are contribute most often to the system time will have a higher count. bk: 3f3a4130e2nY99X11xikJO6QpbOjWA --- diff --git a/include/ntp.h b/include/ntp.h index 8806a6206e..eca3f1981f 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -342,6 +342,7 @@ struct peer { u_long oldpkt; /* packets duplicate packet */ u_long seldisptoolarge; /* packets dispersion to large*/ u_long selbroken; /* not used */ + u_long rank; /* number of times selected or in cluster */ }; /* diff --git a/include/ntp_control.h b/include/ntp_control.h index 0fc726f653..c75d38b31a 100644 --- a/include/ntp_control.h +++ b/include/ntp_control.h @@ -217,15 +217,16 @@ struct ntp_control { #define CP_FILTERROR 34 #define CP_FLASH 35 #define CP_TTL 36 -#define CP_VARLIST 37 +#define CP_RANK 37 +#define CP_VARLIST 38 #ifdef OPENSSL -#define CP_FLAGS 38 -#define CP_HOST 39 -#define CP_INITSEQ 40 -#define CP_INITKEY 41 -#define CP_INITTSP 42 -#define CP_DIGEST 43 -#define CP_IDENT 44 +#define CP_FLAGS 39 +#define CP_HOST 40 +#define CP_INITSEQ 41 +#define CP_INITKEY 42 +#define CP_INITTSP 43 +#define CP_DIGEST 44 +#define CP_IDENT 45 #define CP_MAXCODE CP_IDENT #else #define CP_MAXCODE CP_VARLIST diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index b8325818a0..568d032061 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -202,17 +202,18 @@ static struct ctl_var peer_var[] = { { CP_FILTERROR, RO, "filtdisp=" }, /* 34 */ { CP_FLASH, RO, "flash" }, /* 35 */ { CP_TTL, RO, "ttl" }, /* 36 */ - { CP_VARLIST, RO, "peer_var_list" }, /* 37 */ + { CP_RANK, RO, "rank" }, /* 37 */ + { CP_VARLIST, RO, "peer_var_list" }, /* 38 */ #ifdef OPENSSL - { CP_FLAGS, RO, "flags" }, /* 38 */ - { CP_HOST, RO, "hostname" }, /* 39 */ - { CP_INITSEQ, RO, "initsequence" }, /* 40 */ - { CP_INITKEY, RO, "initkey" }, /* 41 */ - { CP_INITTSP, RO, "timestamp" }, /* 42 */ - { CP_DIGEST, RO, "signature" }, /* 43 */ - { CP_IDENT, RO, "identity" }, /* 44 */ + { CP_FLAGS, RO, "flags" }, /* 39 */ + { CP_HOST, RO, "hostname" }, /* 40 */ + { CP_INITSEQ, RO, "initsequence" }, /* 41 */ + { CP_INITKEY, RO, "initkey" }, /* 42 */ + { CP_INITTSP, RO, "timestamp" }, /* 43 */ + { CP_DIGEST, RO, "signature" }, /* 44 */ + { CP_IDENT, RO, "identity" }, /* 45 */ #endif /* OPENSSL */ - { 0, EOV, "" } /* 38/43 */ + { 0, EOV, "" } /* 39/46 */ }; @@ -1527,6 +1528,10 @@ ctl_putpeer( ctl_putuint(peer_var[CP_VALID].text, peer->unreach); break; + case CP_RANK: + ctl_putuint(peer_var[CP_RANK].text, peer->rank); + break; + case CP_TIMER: ctl_putuint(peer_var[CP_TIMER].text, peer->nextdate - current_time); diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index cbb50a8455..5179b76e8b 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -750,6 +750,7 @@ peer_reset( peer->oldpkt = 0; peer->seldisptoolarge = 0; peer->selbroken = 0; + peer->rank = 0; peer->timereset = current_time; } diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 66d7861647..e1d0f1010e 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -2158,6 +2158,7 @@ clock_select(void) peer = peer_list[i]; leap_consensus |= peer->leap; peer->status = CTL_PST_SEL_SYNCCAND; + peer->rank++; peer->flags |= FLAG_SYSPEER; if (peer->stratum >= sys_floor && osurv >= sys_minclock) peer->hyst = HYST; @@ -2237,6 +2238,7 @@ clock_select(void) else sys_peer = peer_list[0]; sys_peer->status = CTL_PST_SEL_SYSPEER; + sys_peer->rank++; sys_offset = clock_combine(peer_list, nlist); sys_syserr = sys_peer->jitter + sys_selerr; #ifdef DEBUG