diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2005-02-03 10:53:34 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2005-02-03 10:53:34 +0000 |
commit | 3ba1593ebbef439c9c89cd1ccb5a159017057aa1 (patch) | |
tree | 56b1e4d021b258b4dd30d98fb836c1dee9ebc8a0 /usr.sbin | |
parent | 29d88779e863d7e7a04d3dbc91f2abed6b5f60ed (diff) |
Implement simple duplicate suppression of peer errors; ok henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/client.c | 20 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.h | 4 |
2 files changed, 20 insertions, 4 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c index ac3bcea279f..4a6bd9d648c 100644 --- a/usr.sbin/ntpd/client.c +++ b/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.55 2005/01/28 12:37:20 dtucker Exp $ */ +/* $OpenBSD: client.c,v 1.56 2005/02/03 10:53:33 dtucker Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -53,6 +53,7 @@ client_peer_init(struct ntp_peer *p) p->state = STATE_NONE; p->shift = 0; p->trustlevel = TRUSTLEVEL_PATHETIC; + p->lasterror = 0; return (client_addr_init(p)); } @@ -182,8 +183,7 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime) if (errno == EHOSTUNREACH || errno == EHOSTDOWN || errno == ENETUNREACH || errno == ENETDOWN || errno == ECONNREFUSED) { - log_warn("recvfrom %s", - log_sockaddr((struct sockaddr *)&p->addr->ss)); + client_log_error(p, "recvfrom", errno); set_next(p, error_interval()); return (0); } else @@ -311,3 +311,17 @@ client_update(struct ntp_peer *p) return (0); } + +void +client_log_error(struct ntp_peer *peer, const char *operation, int error) +{ + const char *address; + + address = log_sockaddr((struct sockaddr *)&peer->addr->ss); + if (peer->lasterror == error) { + log_debug("%s %s", operation, address); + return; + } + peer->lasterror = error; + log_warn("%s %s", operation, address); +} diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index 0be48157ad9..70ad6709c58 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.52 2005/02/02 18:57:09 henning Exp $ */ +/* $OpenBSD: ntpd.h,v 1.53 2005/02/03 10:53:33 dtucker Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -113,6 +113,7 @@ struct ntp_peer { u_int32_t id; u_int8_t shift; u_int8_t trustlevel; + int lasterror; }; struct ntpd_conf { @@ -238,6 +239,7 @@ int client_addr_init(struct ntp_peer *); int client_nextaddr(struct ntp_peer *); int client_query(struct ntp_peer *); int client_dispatch(struct ntp_peer *, u_int8_t); +void client_log_error(struct ntp_peer *, const char *, int); void update_scale(double); time_t scale_interval(time_t); time_t error_interval(void); |