From: Luis Dallos Date: Tue, 2 Aug 2022 03:00:25 +0000 (-0400) Subject: Fix startup failure on Windows 8.1 due to unsupported IPV6_USER_MTU socket option... X-Git-Tag: release-1.17.0rc1~42^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F730%2Fhead;p=thirdparty%2Funbound.git Fix startup failure on Windows 8.1 due to unsupported IPV6_USER_MTU socket option being set Newer mingw-w64 (starting from 8.0.1) introduces support for `IPV6_USER_MTU` socket option [1], which is not supported on Windows 8.1 and older [2]. As there is no way to avoid this socket option from being picked at compile time when targeting older versions of Windows, check for `setsockopt(..., IPV6_USER_MTU, ...)` failures at runtime in order to avoid startup failure on those versions of Windows where the `IPV6_USER_MTU` socket option is unsupported. [1]: mirror/mingw-w64@e30bff4 [2]: `WSAGetLastError()` returns `WSAENOPROTOOPT` (`Bad protocol option`) error code --- diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 1c7c177a0..467419b09 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -511,12 +511,14 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, * instead which is writable; IPV6_MTU is readonly there. */ if (setsockopt(s, IPPROTO_IPV6, IPV6_USER_MTU, (void*)&mtu, (socklen_t)sizeof(mtu)) < 0) { - log_err("setsockopt(..., IPV6_USER_MTU, ...) failed: %s", - wsa_strerror(WSAGetLastError())); - sock_close(s); - *noproto = 0; - *inuse = 0; - return -1; + if (WSAGetLastError() != WSAENOPROTOOPT) { + log_err("setsockopt(..., IPV6_USER_MTU, ...) failed: %s", + wsa_strerror(WSAGetLastError())); + sock_close(s); + *noproto = 0; + *inuse = 0; + return -1; + } } # endif /* USE_WINSOCK */ # endif /* IPv6 MTU */