summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/ntp.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2006-05-28 20:39:17 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2006-05-28 20:39:17 +0000
commit981effaf560041db6d968d027db9a965425f687f (patch)
tree14f6deb2ba407621d8a62a543aa42d7fce7b3112 /usr.sbin/ntpd/ntp.c
parent5adbba24d97a16b379dd00c5ca6f0cb443dfa5a3 (diff)
allow for weight to be added to sensors or servers, so that one can
weight timedelta sensors higher than ntp peers, for example ok deraadt mbalmer
Diffstat (limited to 'usr.sbin/ntpd/ntp.c')
-rw-r--r--usr.sbin/ntpd/ntp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 3d1c0c6a417..0bf8bc279ac 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.76 2006/05/28 18:47:25 henning Exp $ */
+/* $OpenBSD: ntp.c,v 1.77 2006/05/28 20:39:16 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -422,7 +422,7 @@ priv_adjtime(void)
{
struct ntp_peer *p;
struct ntp_sensor *s;
- int offset_cnt = 0, i = 0;
+ int offset_cnt = 0, i = 0, j;
struct ntp_offset **offsets;
double offset_median;
@@ -431,13 +431,13 @@ priv_adjtime(void)
continue;
if (!p->update.good)
return;
- offset_cnt++;
+ offset_cnt += p->weight;
}
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
continue;
- offset_cnt++;
+ offset_cnt += p->weight;
}
if ((offsets = calloc(offset_cnt, sizeof(struct ntp_offset *))) == NULL)
@@ -446,13 +446,15 @@ priv_adjtime(void)
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->trustlevel < TRUSTLEVEL_BADPEER)
continue;
- offsets[i++] = &p->update;
+ for (j = 0; j < p->weight; j++)
+ offsets[i++] = &p->update;
}
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
continue;
- offsets[i++] = &s->update;
+ for (j = 0; j < s->weight; j++)
+ offsets[i++] = &s->update;
}
qsort(offsets, offset_cnt, sizeof(struct ntp_offset *), offset_compare);