diff options
Diffstat (limited to 'vendor/golang.org/x/net/internal/nettest/helper_bsd.go')
-rw-r--r-- | vendor/golang.org/x/net/internal/nettest/helper_bsd.go | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/vendor/golang.org/x/net/internal/nettest/helper_bsd.go b/vendor/golang.org/x/net/internal/nettest/helper_bsd.go index b2308a0e8..a6e433b58 100644 --- a/vendor/golang.org/x/net/internal/nettest/helper_bsd.go +++ b/vendor/golang.org/x/net/internal/nettest/helper_bsd.go @@ -13,6 +13,23 @@ import ( "syscall" ) +var darwinVersion int + +func init() { + if runtime.GOOS == "darwin" { + // See http://support.apple.com/kb/HT1633. + s, err := syscall.Sysctl("kern.osrelease") + if err != nil { + return + } + ss := strings.Split(s, ".") + if len(ss) == 0 { + return + } + darwinVersion, _ = strconv.Atoi(ss[0]) + } +} + func supportsIPv6MulticastDeliveryOnLoopback() bool { switch runtime.GOOS { case "freebsd": @@ -22,27 +39,15 @@ func supportsIPv6MulticastDeliveryOnLoopback() bool { // packets correctly. return false case "darwin": - // See http://support.apple.com/kb/HT1633. - s, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return false - } - ss := strings.Split(s, ".") - if len(ss) == 0 { - return false - } - // OS X 10.9 (Darwin 13) or above seems to do the - // right thing; preserving the packet header as it's - // needed for the checksum calcuration with pseudo - // header on loopback multicast delivery process. - // If not, you'll probably see what is the slow-acting - // kernel crash caused by lazy mbuf corruption. - // See ip6_mloopback in netinet6/ip6_output.c. - if mjver, err := strconv.Atoi(ss[0]); err != nil || mjver < 13 { - return false - } - return true + return !causesIPv6Crash() default: return true } } + +func causesIPv6Crash() bool { + // We see some kernel crash when running IPv6 with IP-level + // options on Darwin kernel version 12 or below. + // See golang.org/issues/17015. + return darwinVersion < 13 +} |