diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2012-08-16 14:04:05 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2012-08-16 14:04:05 +0100 |
commit | 5f11b3e5e035f0f3cf523ac5a8403eb890868eea (patch) | |
tree | 79d60a67ce545a72e1c0a0d6a1446e4e04e83253 | |
parent | 3169daad4692213a7efc4f204505a23741bc46e7 (diff) | |
download | dnsmasq-5f11b3e5e035f0f3cf523ac5a8403eb890868eea.tar.gz |
-rw-r--r-- | src/network.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/network.c b/src/network.c index 90fdde9..fda50bd 100644 --- a/src/network.c +++ b/src/network.c @@ -338,13 +338,22 @@ static int make_sock(union mysockaddr *addr, int type, int dienow) sprintf(daemon->addrbuff, "port %d", port); s = _("failed to create listening socket for %s: %s"); + if (fd != -1) + close (fd); + if (dienow) - die(s, daemon->addrbuff, EC_BADNET); + { + /* failure to bind addresses given by --listen-address at this point + is OK if we're doing bind-dynamic */ + if (!option_bool(OPT_CLEVERBIND)) + die(s, daemon->addrbuff, EC_BADNET); + } + else + my_syslog(LOG_WARNING, s, daemon->addrbuff, strerror(errno)); - my_syslog(LOG_ERR, s, daemon->addrbuff, strerror(errno)); return -1; } - + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 || !fix_fd(fd)) goto err; @@ -513,7 +522,8 @@ void create_bound_listeners(int dienow) no interface with a matching address. These may be valid: eg it's possible to listen on 127.0.1.1 even if the loopback interface is 127.0.0.1 - If the address isn't valid the bind() will fail and we'll die(). + If the address isn't valid the bind() will fail and we'll die() + (except in bind-dynamic mode, when we'll complain but keep trying.) The resulting listeners have the ->iface field NULL, and this has to be handled by the DNS and TFTP code. It disables --localise-queries processing |