Browse Source

in server mode reply with stratum from the peer that we currently prefer

plus one
OPENBSD_3_7
henning 19 years ago
parent
commit
d94b864a67
5 changed files with 17 additions and 8 deletions
  1. +2
    -1
      src/usr.sbin/ntpd/client.c
  2. +8
    -2
      src/usr.sbin/ntpd/ntp.c
  3. +3
    -2
      src/usr.sbin/ntpd/ntp_msg.c
  4. +2
    -1
      src/usr.sbin/ntpd/ntpd.h
  5. +2
    -2
      src/usr.sbin/ntpd/server.c

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

@ -1,4 +1,4 @@
/* $OpenBSD: client.c,v 1.42 2004/10/15 01:58:04 dtucker Exp $ */
/* $OpenBSD: client.c,v 1.43 2004/10/22 21:17:37 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -229,6 +229,7 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
p->reply[p->shift].status.refid = ntohl(msg.refid);
p->reply[p->shift].status.reftime = lfp_to_d(msg.reftime);
p->reply[p->shift].status.poll = msg.ppoll;
p->reply[p->shift].status.stratum = msg.stratum;
if (p->trustlevel < TRUSTLEVEL_PATHETIC)
interval = INTERVAL_QUERY_PATHETIC;


+ 8
- 2
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.37 2004/10/13 14:02:50 henning Exp $ */
/* $OpenBSD: ntp.c,v 1.38 2004/10/22 21:17:37 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -380,17 +380,23 @@ ntp_adjtime(void)
conf->status.rootdelay =
(peers[offset_cnt / 2 - 1]->update.delay +
peers[offset_cnt / 2]->update.delay) / 2;
conf->status.stratum = MAX(
peers[offset_cnt / 2 - 1]->update.status.stratum,
peers[offset_cnt / 2]->update.status.stratum);
} else {
offset_median = peers[offset_cnt / 2]->update.offset;
conf->status.rootdelay =
peers[offset_cnt / 2]->update.delay;
conf->status.stratum =
peers[offset_cnt / 2]->update.status.stratum;
}
imsg_compose(ibuf_main, IMSG_ADJTIME, 0, 0,
&offset_median, sizeof(offset_median));
conf->status.reftime = gettime();
conf->status.leap = LI_NOWARNING; /* XXX */
conf->status.leap = LI_NOWARNING;
conf->status.stratum++; /* one more than selected peer */
if (peers[offset_cnt / 2]->addr->ss.ss_family == AF_INET)
conf->status.refid = ((struct sockaddr_in *)


+ 3
- 2
src/usr.sbin/ntpd/ntp_msg.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp_msg.c,v 1.9 2004/10/13 13:35:19 henning Exp $ */
/* $OpenBSD: ntp_msg.c,v 1.10 2004/10/22 21:17:37 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -30,7 +30,8 @@ int
ntp_getmsg(char *p, ssize_t len, struct ntp_msg *msg)
{
if (len != NTP_MSGSIZE_NOAUTH && len != NTP_MSGSIZE) {
log_warnx("malformed packet received");
log_warnx("malformed packet received: len is %d should be %d "
"or with auth %d", len, NTP_MSGSIZE_NOAUTH, NTP_MSGSIZE);
return (-1);
}


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.40 2004/10/14 09:35:48 dtucker Exp $ */
/* $OpenBSD: ntpd.h,v 1.41 2004/10/22 21:17:37 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -83,6 +83,7 @@ struct ntp_status {
u_int32_t refid;
double reftime;
u_int8_t poll;
u_int8_t stratum;
};
struct ntp_offset {


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

@ -1,4 +1,4 @@
/* $OpenBSD: server.c,v 1.17 2004/10/15 01:58:04 dtucker Exp $ */
/* $OpenBSD: server.c,v 1.18 2004/10/22 21:17:37 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -134,7 +134,7 @@ server_dispatch(int fd, struct ntpd_conf *conf)
else
reply.status |= MODE_SYM_PAS;
reply.stratum = 2;
reply.stratum = conf->status.stratum;
reply.ppoll = query.ppoll;
reply.precision = conf->status.precision;
reply.rectime = d_to_lfp(rectime);


Loading…
Cancel
Save