Browse Source

Implement simple duplicate suppression of peer errors; ok henning@

OPENBSD_3_7
dtucker 20 years ago
parent
commit
c1809222fb
2 changed files with 20 additions and 4 deletions
  1. +17
    -3
      src/usr.sbin/ntpd/client.c
  2. +3
    -1
      src/usr.sbin/ntpd/ntpd.h

+ 17
- 3
src/usr.sbin/ntpd/client.c View File

@ -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> * 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->state = STATE_NONE;
p->shift = 0; p->shift = 0;
p->trustlevel = TRUSTLEVEL_PATHETIC; p->trustlevel = TRUSTLEVEL_PATHETIC;
p->lasterror = 0;
return (client_addr_init(p)); return (client_addr_init(p));
} }
@ -182,8 +183,7 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
if (errno == EHOSTUNREACH || errno == EHOSTDOWN || if (errno == EHOSTUNREACH || errno == EHOSTDOWN ||
errno == ENETUNREACH || errno == ENETDOWN || errno == ENETUNREACH || errno == ENETDOWN ||
errno == ECONNREFUSED) { errno == ECONNREFUSED) {
log_warn("recvfrom %s",
log_sockaddr((struct sockaddr *)&p->addr->ss));
client_log_error(p, "recvfrom", errno);
set_next(p, error_interval()); set_next(p, error_interval());
return (0); return (0);
} else } else
@ -311,3 +311,17 @@ client_update(struct ntp_peer *p)
return (0); 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);
}

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

@ -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> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -113,6 +113,7 @@ struct ntp_peer {
u_int32_t id; u_int32_t id;
u_int8_t shift; u_int8_t shift;
u_int8_t trustlevel; u_int8_t trustlevel;
int lasterror;
}; };
struct ntpd_conf { struct ntpd_conf {
@ -238,6 +239,7 @@ int client_addr_init(struct ntp_peer *);
int client_nextaddr(struct ntp_peer *); int client_nextaddr(struct ntp_peer *);
int client_query(struct ntp_peer *); int client_query(struct ntp_peer *);
int client_dispatch(struct ntp_peer *, u_int8_t); int client_dispatch(struct ntp_peer *, u_int8_t);
void client_log_error(struct ntp_peer *, const char *, int);
void update_scale(double); void update_scale(double);
time_t scale_interval(time_t); time_t scale_interval(time_t);
time_t error_interval(void); time_t error_interval(void);


Loading…
Cancel
Save