From 1cd88ffd3158d8887fe129456980df5f9570f47a Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Thu, 25 May 2006 19:25:47 +0000 Subject: figure out the refid to send to NTP v3 clients early and store it first bits from a way to long flight --- usr.sbin/ntpd/client.c | 8 +++++++- usr.sbin/ntpd/ntp.c | 9 +++------ usr.sbin/ntpd/ntpd.h | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'usr.sbin/ntpd') diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c index 208672bfa8e..4e30f465bb7 100644 --- a/usr.sbin/ntpd/client.c +++ b/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.66 2005/09/24 00:32:03 dtucker Exp $ */ +/* $OpenBSD: client.c,v 1.67 2006/05/25 19:25:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -256,6 +256,12 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime) p->reply[p->shift].status.poll = msg.ppoll; p->reply[p->shift].status.stratum = msg.stratum; + if (p->addr->ss.ss_family == AF_INET) + p->reply[p->shift].status.send_refid = + ((struct sockaddr_in *)&p->addr->ss)->sin_addr.s_addr; + else + p->reply[p->shift].status.send_refid = msg.xmttime.fractionl; + if (p->trustlevel < TRUSTLEVEL_PATHETIC) interval = scale_interval(INTERVAL_QUERY_PATHETIC); else if (p->trustlevel < TRUSTLEVEL_AGRESSIVE) diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index f27e42a4c15..1a476c611b0 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.68 2006/05/14 22:33:51 henning Exp $ */ +/* $OpenBSD: ntp.c,v 1.69 2006/05/25 19:25:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -444,11 +444,8 @@ priv_adjtime(void) conf->status.refid4 = peers[offset_cnt / 2]->update.status.refid4; - if (peers[offset_cnt / 2]->addr->ss.ss_family == AF_INET) - conf->status.refid = ((struct sockaddr_in *) - &peers[offset_cnt / 2]->addr->ss)->sin_addr.s_addr; - else - conf->status.refid = conf->status.refid4; + conf->status.refid = + peers[offset_cnt / 2]->update.status.send_refid; } free(peers); diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index fabca3a3033..7466a69a6be 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.61 2005/09/24 00:32:03 dtucker Exp $ */ +/* $OpenBSD: ntpd.h,v 1.62 2006/05/25 19:25:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -90,6 +90,7 @@ struct ntp_status { double reftime; u_int32_t refid; u_int32_t refid4; + u_int32_t send_refid; u_int8_t synced; u_int8_t leap; int8_t precision; -- cgit v1.2.3