summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/net/internal/nettest/helper_bsd.go
blob: b2308a0e8f17c21c382d8c9c6756509f209068f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build darwin dragonfly freebsd netbsd openbsd

package nettest

import (
	"runtime"
	"strconv"
	"strings"
	"syscall"
)

func supportsIPv6MulticastDeliveryOnLoopback() bool {
	switch runtime.GOOS {
	case "freebsd":
		// See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
		// Even after the fix, it looks like the latest
		// kernels don't deliver link-local scoped multicast
		// 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
	default:
		return true
	}
}