Browse Source

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.
OPENBSD_3_7
henning 20 years ago
parent
commit
a4e395e47f
2 changed files with 11 additions and 4 deletions
  1. +9
    -3
      src/usr.sbin/ntpd/ntp.c
  2. +2
    -1
      src/usr.sbin/ntpd/server.c

+ 9
- 3
src/usr.sbin/ntpd/ntp.c View File

@ -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));


+ 2
- 1
src/usr.sbin/ntpd/server.c View File

@ -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;


Loading…
Cancel
Save