Browse Source

If a bind() spuriously fails (as appears to happen once in a blue moon due

to some stupid ipv6 bug in particular), remove that 'listen' from the list
and continue operation.  issue spotted by naddy
ok henning
OPENBSD_4_5
deraadt 16 years ago
parent
commit
7a1c705b0b
1 changed files with 17 additions and 6 deletions
  1. +17
    -6
      src/usr.sbin/ntpd/server.c

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

@ -1,4 +1,4 @@
/* $OpenBSD: server.c,v 1.32 2008/06/10 03:46:09 naddy Exp $ */
/* $OpenBSD: server.c,v 1.33 2008/11/10 16:59:33 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -75,9 +75,7 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
freeifaddrs(ifa);
}
TAILQ_FOREACH(la, &lconf->listen_addrs, entry) {
new_cnt++;
for (la = TAILQ_FIRST(&lconf->listen_addrs); la; ) {
switch (la->sa.ss_family) {
case AF_INET:
if (((struct sockaddr_in *)&la->sa)->sin_port == 0)
@ -104,8 +102,21 @@ setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt)
log_warn("setsockopt IPTOS_LOWDELAY");
if (bind(la->fd, (struct sockaddr *)&la->sa,
SA_LEN((struct sockaddr *)&la->sa)) == -1)
fatal("bind");
SA_LEN((struct sockaddr *)&la->sa)) == -1) {
struct listen_addr *nla;
log_warn("bind on %s failed, skipping",
log_sockaddr((struct sockaddr *)&la->sa));
close(la->fd);
la->fd = -1;
nla = TAILQ_NEXT(la, entry);
TAILQ_REMOVE(&lconf->listen_addrs, la, entry);
free(la);
la = nla;
continue;
}
new_cnt++;
la = TAILQ_NEXT(la, entry);
}
*cnt = new_cnt;


Loading…
Cancel
Save