|
@@ -13,6 +13,23 @@ import (
|
|
|
"syscall"
|
|
"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 {
|
|
func supportsIPv6MulticastDeliveryOnLoopback() bool {
|
|
|
switch runtime.GOOS {
|
|
switch runtime.GOOS {
|
|
|
case "freebsd":
|
|
case "freebsd":
|
|
@@ -22,27 +39,15 @@ func supportsIPv6MulticastDeliveryOnLoopback() bool {
|
|
|
// packets correctly.
|
|
// packets correctly.
|
|
|
return false
|
|
return false
|
|
|
case "darwin":
|
|
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:
|
|
default:
|
|
|
return true
|
|
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
|
|
|
|
|
+}
|