diff --git a/udp/udp_tester.go b/udp/udp_tester.go index c9161c89..f80758a9 100644 --- a/udp/udp_tester.go +++ b/udp/udp_tester.go @@ -11,7 +11,6 @@ import ( "os" "sync" "sync/atomic" - "syscall" "github.com/slackhq/nebula/config" "github.com/slackhq/nebula/header" @@ -118,7 +117,7 @@ func (u *TesterConn) SetAddr(addr netip.AddrPort) { // SetDualStackAddrs gives this conn one underlay address per family, standing in for a host whose routing table picks // the source by destination. Pass an invalid AddrPort for a family the network does not offer, sends to that family -// then fail with ENETUNREACH like they would on a host with no route for it. +// then fail like they would on a host with no route for it. func (u *TesterConn) SetDualStackAddrs(v4, v6 netip.AddrPort) { a := &testerAddrs{v4: v4, v6: v6, dual: true} if v4.IsValid() { @@ -149,7 +148,7 @@ func (u *TesterConn) sourceFor(dst netip.AddrPort) (netip.AddrPort, error) { src = a.v4 } if !src.IsValid() { - return netip.AddrPort{}, &net.OpError{Op: "write", Net: "udp", Addr: net.UDPAddrFromAddrPort(dst), Err: syscall.ENETUNREACH} + return netip.AddrPort{}, &net.OpError{Op: "write", Net: "udp", Addr: net.UDPAddrFromAddrPort(dst), Err: errNetUnreachable} } return src, nil } diff --git a/udp/unreachable.go b/udp/unreachable.go index ccec0fc4..7f0ba8df 100644 --- a/udp/unreachable.go +++ b/udp/unreachable.go @@ -7,6 +7,9 @@ import ( "syscall" ) +// errNetUnreachable is the error this platform's sockets give for a destination with no route +var errNetUnreachable error = syscall.ENETUNREACH + // IsUnreachable reports whether a send failed because this host has no way to reach the destination from where it // is now, rather than for something transient. Moving from a dual stack network to one without IPv6 turns every send // to an IPv6 remote into one of these. diff --git a/udp/unreachable_windows.go b/udp/unreachable_windows.go index fe8178a7..4d7c4700 100644 --- a/udp/unreachable_windows.go +++ b/udp/unreachable_windows.go @@ -6,6 +6,9 @@ import ( "golang.org/x/sys/windows" ) +// errNetUnreachable is the error this platform's sockets give for a destination with no route +var errNetUnreachable error = windows.WSAENETUNREACH + // IsUnreachable reports whether a send failed because this host has no way to reach the destination from where it // is now, rather than for something transient. Moving from a dual stack network to one without IPv6 turns every send // to an IPv6 remote into one of these.