helper_bsd.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // 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. // +build darwin dragonfly freebsd netbsd openbsd
  5. package nettest
  6. import (
  7. "runtime"
  8. "strconv"
  9. "strings"
  10. "syscall"
  11. )
  12. var darwinVersion int
  13. func init() {
  14. if runtime.GOOS == "darwin" {
  15. // See http://support.apple.com/kb/HT1633.
  16. s, err := syscall.Sysctl("kern.osrelease")
  17. if err != nil {
  18. return
  19. }
  20. ss := strings.Split(s, ".")
  21. if len(ss) == 0 {
  22. return
  23. }
  24. darwinVersion, _ = strconv.Atoi(ss[0])
  25. }
  26. }
  27. func supportsIPv6MulticastDeliveryOnLoopback() bool {
  28. switch runtime.GOOS {
  29. case "freebsd":
  30. // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
  31. // Even after the fix, it looks like the latest
  32. // kernels don't deliver link-local scoped multicast
  33. // packets correctly.
  34. return false
  35. case "darwin":
  36. return !causesIPv6Crash()
  37. default:
  38. return true
  39. }
  40. }
  41. func causesIPv6Crash() bool {
  42. // We see some kernel crash when running IPv6 with IP-level
  43. // options on Darwin kernel version 12 or below.
  44. // See golang.org/issues/17015.
  45. return darwinVersion < 13
  46. }