github.com/slackhq/nebula@v1.9.0/udp/udp_netbsd.go (about) 1 //go:build !e2e_testing 2 // +build !e2e_testing 3 4 package udp 5 6 // FreeBSD support is primarily implemented in udp_generic, besides NewListenConfig 7 8 import ( 9 "fmt" 10 "net" 11 "syscall" 12 13 "github.com/sirupsen/logrus" 14 "golang.org/x/sys/unix" 15 ) 16 17 func NewListener(l *logrus.Logger, ip net.IP, port int, multi bool, batch int) (Conn, error) { 18 return NewGenericListener(l, ip, port, multi, batch) 19 } 20 21 func NewListenConfig(multi bool) net.ListenConfig { 22 return net.ListenConfig{ 23 Control: func(network, address string, c syscall.RawConn) error { 24 if multi { 25 var controlErr error 26 err := c.Control(func(fd uintptr) { 27 if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { 28 controlErr = fmt.Errorf("SO_REUSEPORT failed: %v", err) 29 return 30 } 31 }) 32 if err != nil { 33 return err 34 } 35 if controlErr != nil { 36 return controlErr 37 } 38 } 39 return nil 40 }, 41 } 42 } 43 44 func (u *GenericConn) Rebind() error { 45 return nil 46 }