summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ntpd/client.c5
-rw-r--r--usr.sbin/ntpd/ntp.c20
-rw-r--r--usr.sbin/ntpd/ntpd.h4
3 files changed, 21 insertions, 8 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index 157e06c13e8..0eae0c5bbcc 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.78 2007/12/27 01:46:50 stevesk Exp $ */
+/* $OpenBSD: client.c,v 1.79 2008/01/28 11:45:59 mpf Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -54,6 +54,7 @@ client_peer_init(struct ntp_peer *p)
p->shift = 0;
p->trustlevel = TRUSTLEVEL_PATHETIC;
p->lasterror = 0;
+ p->senderrors = 0;
return (client_addr_init(p));
}
@@ -172,11 +173,13 @@ client_query(struct ntp_peer *p)
if (ntp_sendmsg(p->query->fd, NULL, &p->query->msg,
NTP_MSGSIZE_NOAUTH, 0) == -1) {
+ p->senderrors++;
set_next(p, INTERVAL_QUERY_PATHETIC);
p->trustlevel = TRUSTLEVEL_PATHETIC;
return (-1);
}
+ p->senderrors = 0;
p->state = STATE_QUERY_SENT;
set_deadline(p, QUERYTIME_MAX);
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 1da3eef6ca1..28234875813 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.102 2007/12/27 01:46:50 stevesk Exp $ */
+/* $OpenBSD: ntp.c,v 1.103 2008/01/28 11:45:59 mpf Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -229,11 +229,6 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf, struct passwd *pw)
if (client_query(p) == 0)
sent_cnt++;
}
- if (p->next > 0 && p->next < nextaction)
- nextaction = p->next;
-
- if (p->deadline > 0 && p->deadline < nextaction)
- nextaction = p->deadline;
if (p->deadline > 0 && p->deadline <= getmonotime()) {
timeout = error_interval();
log_debug("no reply from %s received in time, "
@@ -247,6 +242,19 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf, struct passwd *pw)
client_nextaddr(p);
set_next(p, timeout);
}
+ if (p->senderrors > MAX_SEND_ERRORS) {
+ log_debug("failed to send query to %s, "
+ "next query %ds", log_sockaddr(
+ (struct sockaddr *)&p->addr->ss),
+ INTERVAL_QUERY_PATHETIC);
+ p->senderrors = 0;
+ client_nextaddr(p);
+ set_next(p, INTERVAL_QUERY_PATHETIC);
+ }
+ if (p->next > 0 && p->next < nextaction)
+ nextaction = p->next;
+ if (p->deadline > 0 && p->deadline < nextaction)
+ nextaction = p->deadline;
if (p->state == STATE_QUERY_SENT &&
p->query->fd != -1) {
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index efbb286ea66..323ca05e21c 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.90 2007/12/23 18:39:50 stevesk Exp $ */
+/* $OpenBSD: ntpd.h,v 1.91 2008/01/28 11:45:59 mpf Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -60,6 +60,7 @@
#define FREQUENCY_SAMPLES 8 /* samples for est. of permanent drift */
#define MAX_FREQUENCY_ADJUST 128e-5 /* max correction per iteration */
#define REPORT_INTERVAL (24*60*60) /* interval between status reports */
+#define MAX_SEND_ERRORS 3 /* max send errors before reconnect */
#define SENSOR_DATA_MAXAGE (15*60)
@@ -130,6 +131,7 @@ struct ntp_peer {
u_int8_t trustlevel;
u_int8_t weight;
int lasterror;
+ int senderrors;
};
struct ntp_sensor {