Skip to content

Commit

Permalink
conn: do not SO_REUSEADDR on linux
Browse files Browse the repository at this point in the history
SO_REUSEADDR does not make sense for unicast UDP sockets.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
  • Loading branch information
zx2c4 committed Dec 18, 2020
1 parent bdda4ac commit 42de652
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions conn/conn_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,6 @@ func create4(port uint16) (int, uint16, error) {
// set sockopts and bind

if err := func() error {
if err := unix.SetsockoptInt(
fd,
unix.SOL_SOCKET,
unix.SO_REUSEADDR,
1,
); err != nil {
return err
}

if err := unix.SetsockoptInt(
fd,
unix.IPPROTO_IP,
Expand Down Expand Up @@ -379,16 +370,6 @@ func create6(port uint16) (int, uint16, error) {
}

if err := func() error {

if err := unix.SetsockoptInt(
fd,
unix.SOL_SOCKET,
unix.SO_REUSEADDR,
1,
); err != nil {
return err
}

if err := unix.SetsockoptInt(
fd,
unix.IPPROTO_IPV6,
Expand Down

0 comments on commit 42de652

Please sign in to comment.