mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 07:56:52 +01:00
Fail dual stack test sends with the platform's own unreachable error
This commit is contained in:
1 parent
b69cf4ecb4
commit
995f22ca53
3 files changed
+8
-3
No files matched your search
+2
-3
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user