mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-01 09:32:08 +00:00
net/netcheck: use DERP frames as a signal for home region liveness
This uses the fact that we've received a frame from a given DERP region within a certain time as a signal that the region is stil present (and thus can still be a node's PreferredDERP / home region) even if we don't get a STUN response from that region during a netcheck. This should help avoid DERP flaps that occur due to losing STUN probes while still having a valid and active TCP connection to the DERP server. RELNOTE=Reduce home DERP flapping when there's still an active connection Updates #8603 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: If7da6312581e1d434d5c0811697319c621e187a0
This commit is contained in:
@@ -360,6 +360,8 @@ func SetDERPRegionHealth(region int, problem string) {
|
||||
selfCheckLocked()
|
||||
}
|
||||
|
||||
// NoteDERPRegionReceivedFrame is called to note that a frame was received from
|
||||
// the given DERP region at the current time.
|
||||
func NoteDERPRegionReceivedFrame(region int) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
@@ -367,6 +369,15 @@ func NoteDERPRegionReceivedFrame(region int) {
|
||||
selfCheckLocked()
|
||||
}
|
||||
|
||||
// GetDERPRegionReceivedTime returns the last time that a frame was received
|
||||
// from the given DERP region, or the zero time if no communication with that
|
||||
// region has occurred.
|
||||
func GetDERPRegionReceivedTime(region int) time.Time {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return derpRegionLastFrame[region]
|
||||
}
|
||||
|
||||
// state is an ipn.State.String() value: "Running", "Stopped", "NeedsLogin", etc.
|
||||
func SetIPNState(state string, wantRunning bool) {
|
||||
mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user