From 5c9b6e8e63e012513b1cb1a4a08ff23dec4137a1 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Fri, 26 Mar 2021 13:17:36 +0000 Subject: [PATCH] net: never probe IPv4 map support on DragonFly BSD, OpenBSD DragonFly BSD and OpenBSD do not implement mapping IPv4 addresses to the IPv6 address space, and a runtime check can be avoided. As the IP stack capabilities probe was only being called from supportsIPv4map to check for this support, the OS-specific handling can be added to this function rather than continuing to run the probe. Change-Id: I5800c197b1be502a6efa79e3edd6356bde8637fb GitHub-Last-Rev: 7eb67189cd955fb12382a6f2a05f324d2747dcc3 GitHub-Pull-Request: golang/go#45243 Reviewed-on: https://go-review.googlesource.com/c/go/+/304870 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Trust: Tobias Klauser --- src/net/ipsock.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/net/ipsock.go b/src/net/ipsock.go index 7d0684d176..0f5da2577c 100644 --- a/src/net/ipsock.go +++ b/src/net/ipsock.go @@ -7,6 +7,7 @@ package net import ( "context" "internal/bytealg" + "runtime" "sync" ) @@ -44,6 +45,13 @@ func supportsIPv6() bool { // IPv4 address inside an IPv6 address at transport layer // protocols. See RFC 4291, RFC 4038 and RFC 3493. func supportsIPv4map() bool { + // Some operating systems provide no support for mapping IPv4 + // addresses to IPv6, and a runtime check is unnecessary. + switch runtime.GOOS { + case "dragonfly", "openbsd": + return false + } + ipStackCaps.Once.Do(ipStackCaps.probe) return ipStackCaps.ipv4MappedIPv6Enabled } -- 2.50.0