mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
net: tweak the ephemeral port range on dragonfly
On DragonFly BSD, we adjust the ephemeral port range because unlike other BSD systems its default ephemeral port range doesn't conform to IANA recommendation as described in RFC 6355 and is pretty narrow. On DragonFly BSD 3.6: default range [1024, 5000], high range [49152, 65535] On FreeBSD 10: default range [10000, 65535], high range [49152, 65535] On Linux 3.11: default range [32768, 61000] Fixes #7541. LGTM=iant R=jsing, gobot, iant CC=golang-codereviews https://golang.org/cl/80610044
This commit is contained in:
parent
a7858a40a5
commit
83ac901fb9
|
@ -8,10 +8,23 @@ package net
|
|||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func setDefaultSockopts(s, family, sotype int, ipv6only bool) error {
|
||||
if runtime.GOOS == "dragonfly" && sotype != syscall.SOCK_RAW {
|
||||
// On DragonFly BSD, we adjust the ephemeral port
|
||||
// range because unlike other BSD systems its default
|
||||
// port range doesn't conform to IANA recommendation
|
||||
// as described in RFC 6355 and is pretty narrow.
|
||||
switch family {
|
||||
case syscall.AF_INET:
|
||||
syscall.SetsockoptInt(s, syscall.IPPROTO_IP, syscall.IP_PORTRANGE, syscall.IP_PORTRANGE_HIGH)
|
||||
case syscall.AF_INET6:
|
||||
syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_PORTRANGE, syscall.IPV6_PORTRANGE_HIGH)
|
||||
}
|
||||
}
|
||||
if family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW {
|
||||
// Allow both IP versions even if the OS default
|
||||
// is otherwise. Note that some operating systems
|
||||
|
|
|
@ -113,9 +113,17 @@ const (
|
|||
SO_KEEPALIVE
|
||||
SO_LINGER
|
||||
SO_ERROR
|
||||
IP_PORTRANGE
|
||||
IP_PORTRANGE_DEFAULT
|
||||
IP_PORTRANGE_LOW
|
||||
IP_PORTRANGE_HIGH
|
||||
IP_MULTICAST_IF
|
||||
IP_MULTICAST_LOOP
|
||||
IP_ADD_MEMBERSHIP
|
||||
IPV6_PORTRANGE
|
||||
IPV6_PORTRANGE_DEFAULT
|
||||
IPV6_PORTRANGE_LOW
|
||||
IPV6_PORTRANGE_HIGH
|
||||
IPV6_MULTICAST_IF
|
||||
IPV6_MULTICAST_LOOP
|
||||
IPV6_JOIN_GROUP
|
||||
|
|
Loading…
Reference in a new issue