Rework handling of IPv6 address failures
Skip IPv6 on any error getting the default address (::) if IPv6 is not explicitly chosen.
This commit is contained in:
parent
43a82ef6be
commit
ee623a2d84
|
@ -2599,22 +2599,21 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
if (addrfamily == AF_UNSPEC || addrfamily == AF_INET6) {
|
if (addrfamily == AF_UNSPEC || addrfamily == AF_INET6) {
|
||||||
int addr6_res = get_addr(listen_ip6, port, AF_INET6, AI_PASSIVE, &dns6addr);
|
int addr6_res = get_addr(listen_ip6, port, AF_INET6, AI_PASSIVE, &dns6addr);
|
||||||
if (
|
if (addr6_res < 0) {
|
||||||
#ifdef EAI_ADDRFAMILY
|
if (listen_ip6 == NULL) {
|
||||||
addr6_res == EAI_ADDRFAMILY ||
|
|
||||||
#endif
|
|
||||||
addr6_res == EAI_FAMILY) {
|
|
||||||
if (addrfamily == AF_INET6) {
|
if (addrfamily == AF_INET6) {
|
||||||
fprintf(stderr, "IPv6 not supported");
|
fprintf(stderr, "IPv6 not supported");
|
||||||
exit(4);
|
exit(3);
|
||||||
} else {
|
} else {
|
||||||
warnx("IPv6 not supported, skipping");
|
warnx("IPv6 not supported, skipping");
|
||||||
addrfamily = AF_INET;
|
addrfamily = AF_INET;
|
||||||
}
|
}
|
||||||
} else if (addr6_res < 0) {
|
} else {
|
||||||
warnx("Failed to get IPv6 address to listen on: '%s': %s",
|
warnx("Failed to get IPv6 address to listen on: '%s': %s",
|
||||||
listen_ip6, gai_strerror(addr6_res));
|
listen_ip6, gai_strerror(addr6_res));
|
||||||
usage();
|
usage();
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dns6addr_len = addr6_res;
|
dns6addr_len = addr6_res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue