mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-29 07:09:33 +00:00
wgengine/magicsock: make endpoint.discoPing peer relay aware (#16946)
Updates tailscale/corp#30333 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
@@ -994,13 +994,30 @@ func (de *endpoint) discoPing(res *ipnstate.PingResult, size int, cb func(*ipnst
|
|||||||
if derpAddr.IsValid() {
|
if derpAddr.IsValid() {
|
||||||
de.startDiscoPingLocked(epAddr{ap: derpAddr}, now, pingCLI, size, resCB)
|
de.startDiscoPingLocked(epAddr{ap: derpAddr}, now, pingCLI, size, resCB)
|
||||||
}
|
}
|
||||||
if udpAddr.ap.IsValid() && now.Before(de.trustBestAddrUntil) {
|
|
||||||
// Already have an active session, so just ping the address we're using.
|
switch {
|
||||||
// Otherwise "tailscale ping" results to a node on the local network
|
case udpAddr.ap.IsValid() && now.Before(de.trustBestAddrUntil):
|
||||||
// can look like they're bouncing between, say 10.0.0.0/9 and the peer's
|
// We have a "trusted" direct OR peer relay address, ping it.
|
||||||
// IPv6 address, both 1ms away, and it's random who replies first.
|
|
||||||
de.startDiscoPingLocked(udpAddr, now, pingCLI, size, resCB)
|
de.startDiscoPingLocked(udpAddr, now, pingCLI, size, resCB)
|
||||||
} else {
|
if !udpAddr.vni.IsSet() {
|
||||||
|
// If the path is direct we do not want to fallthrough to pinging
|
||||||
|
// all candidate direct paths, otherwise "tailscale ping" results to
|
||||||
|
// a node on the local network can look like they're bouncing
|
||||||
|
// between, say 10.0.0.0/8 and the peer's IPv6 address, both 1ms
|
||||||
|
// away, and it's random who replies first. cb() is called with the
|
||||||
|
// first reply, vs background path discovery that is subject to
|
||||||
|
// betterAddr() comparison and hysteresis
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// If the trusted path is via a peer relay we want to fallthrough in
|
||||||
|
// order to also try all candidate direct paths.
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
// Ping all candidate direct paths. This work overlaps with what
|
||||||
|
// [de.heartbeat] will periodically fire when it calls
|
||||||
|
// [de.sendDiscoPingsLocked], but a user-initiated [pingCLI] is a
|
||||||
|
// "do it now" operation that should not be subject to
|
||||||
|
// [heartbeatInterval] tick or [discoPingInterval] rate-limiting.
|
||||||
for ep := range de.endpointState {
|
for ep := range de.endpointState {
|
||||||
de.startDiscoPingLocked(epAddr{ap: ep}, now, pingCLI, size, resCB)
|
de.startDiscoPingLocked(epAddr{ap: ep}, now, pingCLI, size, resCB)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user