From: Viktor Szakats Date: Sun, 30 Nov 2025 11:52:46 +0000 (+0100) Subject: cf-socket: drop feature check for `IPV6_V6ONLY` on Windows X-Git-Tag: rc-8_18_0-1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=003689c3d37510f7073d203ed94c882c19653fac;p=thirdparty%2Fcurl.git cf-socket: drop feature check for `IPV6_V6ONLY` on Windows The macro is present in all supported Windows toolchains. It's present in mingw-w64 v3+, and in MS SDK 6.0A+ (maybe earlier). Also: - restrict this logic to `USE_WINSOCK` (was: `_WIN32`), to exclude alternate socket libraries (i.e. lwIP). lwIP supports `IPV6_V6ONLY` since its 2.0.0 (2016-11-10) release and it's disabled by default, unlike in Winsock. Ref: https://github.com/lwip-tcpip/lwip/commit/e65202f8257e55b09e6309b1aa405b5e6a017f0d - delete interim setter function/dummy macro `set_ipv6_v6only()`. Follow-up to a28f5f68b965119d9dd1ab6c2a2ccc66c6ed5d1f #18010 Follow-up to ca3f6decb927a4c3eb4c10fba09848b626a526d6 #10975 Closes #19769 --- diff --git a/lib/cf-socket.c b/lib/cf-socket.c index a129959416..0e431976c9 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -83,22 +83,6 @@ #include "curlx/strparse.h" -#if defined(USE_IPV6) && defined(IPV6_V6ONLY) && defined(_WIN32) -/* It makes support for IPv4-mapped IPv6 addresses. - * Linux kernel, NetBSD, FreeBSD and Darwin: default is off; - * Windows Vista and later: default is on; - * DragonFly BSD: acts like off, and dummy setting; - * OpenBSD and earlier Windows: unsupported. - * Linux: controlled by /proc/sys/net/ipv6/bindv6only. - */ -static void set_ipv6_v6only(curl_socket_t sockfd, int on) -{ - (void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)); -} -#else -#define set_ipv6_v6only(x, y) -#endif - static void tcpnodelay(struct Curl_cfilter *cf, struct Curl_easy *data, curl_socket_t sockfd) @@ -1114,7 +1098,18 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf, #ifdef USE_IPV6 if(ctx->addr.family == AF_INET6) { - set_ipv6_v6only(ctx->sock, 0); +#ifdef USE_WINSOCK + /* Turn on support for IPv4-mapped IPv6 addresses. + * Linux kernel, NetBSD, FreeBSD, Darwin, lwIP: default is off; + * Windows Vista and later: default is on; + * DragonFly BSD: acts like off, and dummy setting; + * OpenBSD and earlier Windows: unsupported. + * Linux: controlled by /proc/sys/net/ipv6/bindv6only. + */ + int on = 0; + (void)setsockopt(ctx->sock, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&on, sizeof(on)); +#endif infof(data, " Trying [%s]:%d...", ctx->ip.remote_ip, ctx->ip.remote_port); } else