Fail dual stack test sends with the platform's own unreachable error

This commit is contained in:
JackDoan committed 2026-10-20 14:23:36 -05:00
1 parent b69cf4ecb4
commit 995f22ca53
3 files changed
+8 -3

No files matched your search

+2 -3
View File
@@ -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
}
+3
View File
@@ -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.
+3
View File
@@ -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.