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: e65202f825
- delete interim setter function/dummy macro `set_ipv6_v6only()`.

Follow-up to a28f5f68b9 #18010
Follow-up to ca3f6decb9 #10975

Closes #19769
This commit is contained in:
Viktor Szakats 2025-11-30 12:52:46 +01:00
parent fdf9937cef
commit 003689c3d3
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -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