diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-10-13 14:02:51 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-10-13 14:02:51 +0000 |
commit | 35a205f725182dd70f2ffd62b0879670e8684bcf (patch) | |
tree | be39a5b4eadeb54f5d1b3b7afb0f84b6cdd965d5 | |
parent | ddbbde3deeecc597257d3bca20e527568b67d4df (diff) |
set rootdelay in replies.
inherit rootdelay from the delay from the last client update from the peer
that we picked last time to adjust the local clock.
in some cases we use the average offset between two peers' client updates,
then use the average delay between the two as well.
-rw-r--r-- | usr.sbin/ntpd/ntp.c | 12 | ||||
-rw-r--r-- | usr.sbin/ntpd/server.c | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 6c5e5a4e7d0..c55a333c54b 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.36 2004/10/13 12:22:39 henning Exp $ */ +/* $OpenBSD: ntp.c,v 1.37 2004/10/13 14:02:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -373,12 +373,18 @@ ntp_adjtime(void) qsort(peers, offset_cnt, sizeof(struct ntp_peer *), offset_compare); if (offset_cnt > 0) { - if (offset_cnt > 1 && offset_cnt % 2 == 0) + if (offset_cnt > 1 && offset_cnt % 2 == 0) { offset_median = (peers[offset_cnt / 2 - 1]->update.offset + peers[offset_cnt / 2]->update.offset) / 2; - else + conf->status.rootdelay = + (peers[offset_cnt / 2 - 1]->update.delay + + peers[offset_cnt / 2]->update.delay) / 2; + } else { offset_median = peers[offset_cnt / 2]->update.offset; + conf->status.rootdelay = + peers[offset_cnt / 2]->update.delay; + } imsg_compose(ibuf_main, IMSG_ADJTIME, 0, 0, &offset_median, sizeof(offset_median)); diff --git a/usr.sbin/ntpd/server.c b/usr.sbin/ntpd/server.c index 5fb46a3a070..28574e6eb17 100644 --- a/usr.sbin/ntpd/server.c +++ b/usr.sbin/ntpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.14 2004/10/13 12:22:39 henning Exp $ */ +/* $OpenBSD: server.c,v 1.15 2004/10/13 14:02:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -136,6 +136,7 @@ server_dispatch(int fd, struct ntpd_conf *conf) reply.reftime = d_to_lfp(conf->status.reftime); reply.xmttime = d_to_lfp(gettime()); reply.orgtime = query.xmttime; + reply.rootdelay = d_to_sfp(conf->status.rootdelay); if (version > 3) reply.refid = reply.xmttime.fraction; |