wgengine/magicsock: debug knob to override preferred derp region

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited 2023-12-11 17:18:06 -08:00
parent 2f529d7120
commit 682d9ea896
No known key found for this signature in database
GPG Key ID: 33DF352F65991EB8
3 changed files with 7 additions and 1 deletions

View File

@ -55,7 +55,8 @@
// sockets.
debugEnablePMTUD = envknob.RegisterOptBool("TS_DEBUG_ENABLE_PMTUD")
// debugPMTUD prints extra debugging about peer MTU path discovery.
debugPMTUD = envknob.RegisterBool("TS_DEBUG_PMTUD")
debugPMTUD = envknob.RegisterBool("TS_DEBUG_PMTUD")
debugPreferDERPRegion = envknob.RegisterInt("TS_DEBUG_PREFER_DERP_REGION")
// Hey you! Adding a new debugknob? Make sure to stub it out in the
// debugknobs_stubs.go file too.
)

View File

@ -28,3 +28,4 @@ func debugEnablePMTUD() opt.Bool { return "" }
func debugRingBufferMaxSizeBytes() int { return 0 }
func inTest() bool { return false }
func debugPeerMap() bool { return false }
func debugPreferDERPRegion() int { return 0 }

View File

@ -649,6 +649,10 @@ func (c *Conn) updateNetInfo(ctx context.Context) (*netcheck.Report, error) {
ni.WorkingUDP.Set(report.UDP)
ni.WorkingICMPv4.Set(report.ICMPv4)
ni.PreferredDERP = report.PreferredDERP
preferDERP := debugPreferDERPRegion()
if preferDERP > 0 {
ni.PreferredDERP = preferDERP
}
if ni.PreferredDERP == 0 {
// Perhaps UDP is blocked. Pick a deterministic but arbitrary