net/netcheck: ensure recent history has a full report

suggestExitNodeLocked now ranks exit node candidates using the per-region
latency tracked by the netcheck Client (RecentRegionLatency), which merges
the reports retained in c.prev. That history is only useful for far-away
regions if it contains a full netcheck report, since incremental reports
only re-probe the home region and a handful of the fastest ones.

The full-report cadence in GetReport and the c.prev retention window were
two independent 5-min constants - the way we schedule netchecks ensured
that the history always contaned a full report, but it was not a strong
contract and we did not have any checks around this.

Now full report interval and retention window are driven by the same
var, and a test confirms that the history contains a full report.

Updates tailscale/corp#17516

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
Anton Tolchanov
2026-06-22 12:28:09 +02:00
committed by Anton Tolchanov
parent f442cda999
commit e9e209673e
2 changed files with 62 additions and 1 deletions
+7 -1
View File
@@ -853,7 +853,7 @@ func (c *Client) GetReport(ctx context.Context, dm *tailcfg.DERPMap, opts *GetRe
}
doFull := false
if c.nextFull || now.Sub(c.lastFull) > 5*time.Minute {
if c.nextFull || now.Sub(c.lastFull) > fullReportInterval {
doFull = true
}
// If the last report had a captive portal and reported no UDP access,
@@ -1329,6 +1329,12 @@ func (c *Client) timeNow() time.Time {
}
const (
// fullReportInterval is the maximum time between full netcheck reports.
// Once this long has elapsed since the last full report, the next GetReport
// re-probes every DERP region rather than only the home and fastest regions
// (see GetReport). It also informs retention window for report history
// (c.prev).
fullReportInterval = 5 * time.Minute
// preferredDERPAbsoluteDiff specifies the minimum absolute difference
// in latencies between two DERP regions that would cause a node to
// switch its PreferredDERP ("home DERP"). This ensures that if a node