wgengine/magicsock: move UDP relay path discovery to heartbeat() (#16407)

This was previously hooked around direct UDP path discovery /
CallMeMaybe transmission, and related conditions. Now it is subject to
relay-specific considerations.

Updates tailscale/corp#27502

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited
2025-06-27 13:56:55 -07:00
committed by GitHub
parent 711698f5a9
commit 0a64e86a0d
3 changed files with 118 additions and 18 deletions
+42
View File
@@ -8,6 +8,7 @@ import (
"testing"
"time"
"tailscale.com/tailcfg"
"tailscale.com/types/key"
)
@@ -323,3 +324,44 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
})
}
}
func Test_epAddr_isDirectUDP(t *testing.T) {
vni := virtualNetworkID{}
vni.set(7)
tests := []struct {
name string
ap netip.AddrPort
vni virtualNetworkID
want bool
}{
{
name: "true",
ap: netip.MustParseAddrPort("192.0.2.1:7"),
vni: virtualNetworkID{},
want: true,
},
{
name: "false derp magic addr",
ap: netip.AddrPortFrom(tailcfg.DerpMagicIPAddr, 0),
vni: virtualNetworkID{},
want: false,
},
{
name: "false vni set",
ap: netip.MustParseAddrPort("192.0.2.1:7"),
vni: vni,
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
e := epAddr{
ap: tt.ap,
vni: tt.vni,
}
if got := e.isDirect(); got != tt.want {
t.Errorf("isDirect() = %v, want %v", got, tt.want)
}
})
}
}