Skip to content

Commit

Permalink
fix: ensure we probe STUN regions on incremental netchecks
Browse files Browse the repository at this point in the history
Signed-off-by: Spike Curtis <[email protected]>
  • Loading branch information
spikecurtis committed Oct 30, 2023
1 parent c821c9c commit e0bc011
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion net/netcheck/netcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,11 @@ func makeProbePlan(dm *tailcfg.DERPMap, ifState *interfaces.State, last *Report)
had4 := len(last.RegionV4Latency) > 0
had6 := len(last.RegionV6Latency) > 0
hadBoth := have6if && had4 && had6
// Coder: Some regions don't have STUN, so we need to make sure we have probed
// enough STUN regions
numSTUN := 0
for ri, reg := range sortRegions(dm, last) {
if ri == numIncrementalRegions {
if numSTUN == numIncrementalRegions {
break
}
var p4, p6 []probe
Expand Down Expand Up @@ -459,6 +462,10 @@ func makeProbePlan(dm *tailcfg.DERPMap, ifState *interfaces.State, last *Report)
do6 = false
}
n := reg.Nodes[try%len(reg.Nodes)]
// Coder: The probe won't be valid if the node doesn't have a STUNPort.
if n.STUNPort < 0 {
continue
}
prevLatency := cmpx.Or(
last.RegionLatency[reg.RegionID]*120/100,
defaultActiveRetransmitTime)
Expand All @@ -479,6 +486,9 @@ func makeProbePlan(dm *tailcfg.DERPMap, ifState *interfaces.State, last *Report)
if len(p6) > 0 {
plan[fmt.Sprintf("region-%d-v6", reg.RegionID)] = p6
}
if len(p4) > 0 || len(p6) > 0 {
numSTUN++
}
}
return plan
}
Expand Down

0 comments on commit e0bc011

Please sign in to comment.