Skip to content

Commit fb9d9ba

Browse files
authored
wgengine/magicsock: add TS_DEBUG_NEVER_DIRECT_UDP debug knob (tailscale#17094)
Updates tailscale/corp#30903 Signed-off-by: Jordan Whited <jordan@tailscale.com>
1 parent 32bfd72 commit fb9d9ba

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

wgengine/magicsock/debugknobs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ var (
6262
//
6363
//lint:ignore U1000 used on Linux/Darwin only
6464
debugPMTUD = envknob.RegisterBool("TS_DEBUG_PMTUD")
65+
// debugNeverDirectUDP disables the use of direct UDP connections, forcing
66+
// all peer communication over DERP or peer relay.
67+
debugNeverDirectUDP = envknob.RegisterBool("TS_DEBUG_NEVER_DIRECT_UDP")
6568
// Hey you! Adding a new debugknob? Make sure to stub it out in the
6669
// debugknobs_stubs.go file too.
6770
)

wgengine/magicsock/debugknobs_stubs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ func debugRingBufferMaxSizeBytes() int { return 0 }
3131
func inTest() bool { return false }
3232
func debugPeerMap() bool { return false }
3333
func pretendpoints() []netip.AddrPort { return []netip.AddrPort{} }
34+
func debugNeverDirectUDP() bool { return false }

wgengine/magicsock/endpoint.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,9 @@ func (de *endpoint) startDiscoPingLocked(ep epAddr, now mono.Time, purpose disco
12861286
if runtime.GOOS == "js" {
12871287
return
12881288
}
1289+
if debugNeverDirectUDP() && !ep.vni.IsSet() && ep.ap.Addr() != tailcfg.DerpMagicIPAddr {
1290+
return
1291+
}
12891292
epDisco := de.disco.Load()
12901293
if epDisco == nil {
12911294
return

0 commit comments

Comments
 (0)