diff options
author | Jacob Weinstock <jakobweinstock@gmail.com> | 2022-09-07 10:58:21 -0600 |
---|---|---|
committer | Jacob Weinstock <jakobweinstock@gmail.com> | 2022-09-07 10:58:21 -0600 |
commit | cb978496120c84d3109ff78e8ea1cd919c0ba479 (patch) | |
tree | 6014bff2e03a3aa70ea60dd1e06c91c17ea4cded /dhcpv4/server4 | |
parent | de18a9d48e84748150efb41d6ff584f70a807ecb (diff) |
Update conn_unix.go
Add `SO_REUSEPORT` to aid in debugging and testing.
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Diffstat (limited to 'dhcpv4/server4')
-rw-r--r-- | dhcpv4/server4/conn_unix.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/dhcpv4/server4/conn_unix.go b/dhcpv4/server4/conn_unix.go index da62398..18dd986 100644 --- a/dhcpv4/server4/conn_unix.go +++ b/dhcpv4/server4/conn_unix.go @@ -33,6 +33,10 @@ func NewIPv4UDPConn(iface string, addr *net.UDPAddr) (*net.UDPConn, error) { if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEADDR, 1); err != nil { return nil, fmt.Errorf("cannot set reuseaddr on socket: %v", err) } + // Allow reusing the port to aid debugging and testing. + if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { + return nil, fmt.Errorf("cannot set reuseport on socket: %v", err) + } if len(iface) != 0 { // Bind directly to the interface. if err := dhcpv4.BindToInterface(fd, iface); err != nil { |