ipn/ipnlocal: plumb nodeBackend into suggestExitNode to support delta updates, such as online status changes

Now that (*LocalBackend).suggestExitNodeLocked is never called with a non-current netmap
(the netMap parameter is always nil, indicating that the current netmap should be used),
we can remove the unused parameter.

Additionally, instead of suggestExitNodeLocked passing the most recent full netmap to suggestExitNode,
we now pass the current nodeBackend so it can access peers with delta updates applied.

Finally, with that fixed, we no longer need to skip TestUpdateNetmapDeltaAutoExitNode.

Updates tailscale/corp#29969
Fixes #16455

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl
2025-07-03 14:32:28 -05:00
committed by Nick Khyl
parent 3e01652e4d
commit 4c1c0bac8d
2 changed files with 22 additions and 28 deletions
+6 -3
View File
@@ -57,6 +57,7 @@ import (
"tailscale.com/types/ptr"
"tailscale.com/types/views"
"tailscale.com/util/dnsname"
"tailscale.com/util/eventbus"
"tailscale.com/util/mak"
"tailscale.com/util/must"
"tailscale.com/util/set"
@@ -2327,8 +2328,6 @@ func TestSetExitNodeIDPolicy(t *testing.T) {
}
func TestUpdateNetmapDeltaAutoExitNode(t *testing.T) {
t.Skip("TODO(tailscale/tailscale#16455): suggestExitNode does not check for online status of exit nodes")
peer1 := makePeer(1, withCap(26), withSuggest(), withOnline(true), withExitRoutes())
peer2 := makePeer(2, withCap(26), withSuggest(), withOnline(true), withExitRoutes())
derpMap := &tailcfg.DERPMap{
@@ -4278,7 +4277,11 @@ func TestSuggestExitNode(t *testing.T) {
allowList = set.SetOf(tt.allowPolicy)
}
got, err := suggestExitNode(tt.lastReport, tt.netMap, tt.lastSuggestion, selectRegion, selectNode, allowList)
nb := newNodeBackend(t.Context(), eventbus.New())
defer nb.shutdown(errShutdown)
nb.SetNetMap(tt.netMap)
got, err := suggestExitNode(tt.lastReport, nb, tt.lastSuggestion, selectRegion, selectNode, allowList)
if got.Name != tt.wantName {
t.Errorf("name=%v, want %v", got.Name, tt.wantName)
}