From a4e395e47f453f6ff8d31d7df11558249aa596ba Mon Sep 17 00:00:00 2001 From: henning <> Date: Wed, 13 Oct 2004 14:02:50 +0000 Subject: [PATCH] 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. --- src/usr.sbin/ntpd/ntp.c | 12 +++++++++--- src/usr.sbin/ntpd/server.c | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c index 6c5e5a4e..c55a333c 100644 --- a/src/usr.sbin/ntpd/ntp.c +++ b/src/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 @@ -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/src/usr.sbin/ntpd/server.c b/src/usr.sbin/ntpd/server.c index 5fb46a3a..28574e6e 100644 --- a/src/usr.sbin/ntpd/server.c +++ b/src/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 @@ -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;