From 981effaf560041db6d968d027db9a965425f687f Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Sun, 28 May 2006 20:39:17 +0000 Subject: 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 --- usr.sbin/ntpd/ntp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'usr.sbin/ntpd/ntp.c') 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 @@ -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); -- cgit v1.2.3