From 559dafb03076be53c6be7cc307b12a08ad84e8db Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 9 Aug 2021 12:14:42 +0200 Subject: [PATCH] Attempt skipping IPv6 if not supported --- src/iodined.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/iodined.c b/src/iodined.c index 5c91121..f966531 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -2598,10 +2598,24 @@ main(int argc, char **argv) listen_ip4 = NULL; } if (addrfamily == AF_UNSPEC || addrfamily == AF_INET6) { - dns6addr_len = get_addr(listen_ip6, port, AF_INET6, AI_PASSIVE, &dns6addr); - if (dns6addr_len < 0) { - warnx("Bad IPv6 address to listen on: '%s'", listen_ip6); + int addr6_res = get_addr(listen_ip6, port, AF_INET6, AI_PASSIVE, &dns6addr); + if ( +#ifdef EAI_ADDRFAMILY + addr6_res == EAI_ADDRFAMILY || +#endif + addr6_res == EAI_FAMILY) { + if (addrfamily == AF_INET6) { + fprintf(stderr, "IPv6 not supported"); + exit(4); + } else { + warnx("IPv6 not supported, skipping"); + addrfamily = AF_INET; + } + } else if (addr6_res < 0) { + warn("Failed to get IPv6 address to listen on: '%s'", listen_ip6); usage(); + } else { + dns6addr_len = addr6_res; } // Use dns6addr from here on. listen_ip6 = NULL;