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 ||
|
if (addrfamily == AF_INET6) {
|
||||||
#endif
|
fprintf(stderr, "IPv6 not supported");
|
||||||
addr6_res == EAI_FAMILY) {
|
exit(3);
|
||||||
if (addrfamily == AF_INET6) {
|
} else {
|
||||||
fprintf(stderr, "IPv6 not supported");
|
warnx("IPv6 not supported, skipping");
|
||||||
exit(4);
|
addrfamily = AF_INET;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warnx("IPv6 not supported, skipping");
|
warnx("Failed to get IPv6 address to listen on: '%s': %s",
|
||||||
addrfamily = AF_INET;
|
listen_ip6, gai_strerror(addr6_res));
|
||||||
|
usage();
|
||||||
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
} else if (addr6_res < 0) {
|
|
||||||
warnx("Failed to get IPv6 address to listen on: '%s': %s",
|
|
||||||
listen_ip6, gai_strerror(addr6_res));
|
|
||||||
usage();
|
|
||||||
} else {
|
} else {
|
||||||
dns6addr_len = addr6_res;
|
dns6addr_len = addr6_res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue