2021-03-26 08:46:30 -06:00
|
|
|
// +build !e2e_testing
|
|
|
|
|
2020-05-26 20:23:23 -06:00
|
|
|
package nebula
|
|
|
|
|
|
|
|
// FreeBSD support is primarily implemented in udp_generic, besides NewListenConfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewListenConfig(multi bool) net.ListenConfig {
|
|
|
|
return net.ListenConfig{
|
|
|
|
Control: func(network, address string, c syscall.RawConn) error {
|
|
|
|
if multi {
|
|
|
|
var controlErr error
|
|
|
|
err := c.Control(func(fd uintptr) {
|
|
|
|
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil {
|
|
|
|
controlErr = fmt.Errorf("SO_REUSEPORT failed: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if controlErr != nil {
|
|
|
|
return controlErr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2020-06-30 12:48:58 -06:00
|
|
|
|
2020-09-18 08:20:09 -06:00
|
|
|
func (u *udpConn) Rebind() error {
|
|
|
|
return nil
|
2020-06-30 12:48:58 -06:00
|
|
|
}
|