diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-10 16:59:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-10 16:59:34 +0000 |
commit | 143e86cf2761100a84f9e6087db2d580a14e6505 (patch) | |
tree | 1d8533984e5c602e2da2e9de222e664b9b96692a /usr.sbin | |
parent | 008db9a273f151ac8bec0a0f5f9c2d4207240614 (diff) |
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
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/server.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/ntpd/server.c b/usr.sbin/ntpd/server.c index 6156d522914..56fe4d5522b 100644 --- a/usr.sbin/ntpd/server.c +++ b/usr.sbin/ntpd/server.c @@ -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; |