blob: a6e433b58c109b5d71feae5b14a2a8c055f41536 [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// Copyright 2016 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build darwin dragonfly freebsd netbsd openbsd
6
7package nettest
8
9import (
10 "runtime"
11 "strconv"
12 "strings"
13 "syscall"
14)
15
16var darwinVersion int
17
18func init() {
19 if runtime.GOOS == "darwin" {
20 // See http://support.apple.com/kb/HT1633.
21 s, err := syscall.Sysctl("kern.osrelease")
22 if err != nil {
23 return
24 }
25 ss := strings.Split(s, ".")
26 if len(ss) == 0 {
27 return
28 }
29 darwinVersion, _ = strconv.Atoi(ss[0])
30 }
31}
32
33func supportsIPv6MulticastDeliveryOnLoopback() bool {
34 switch runtime.GOOS {
35 case "freebsd":
36 // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
37 // Even after the fix, it looks like the latest
38 // kernels don't deliver link-local scoped multicast
39 // packets correctly.
40 return false
41 case "darwin":
42 return !causesIPv6Crash()
43 default:
44 return true
45 }
46}
47
48func causesIPv6Crash() bool {
49 // We see some kernel crash when running IPv6 with IP-level
50 // options on Darwin kernel version 12 or below.
51 // See golang.org/issues/17015.
52 return darwinVersion < 13
53}