ipn/ipnlocal: resolve exit node when it arrives by netmap delta (#22184)

Since aa5da2e5f, a peer that control adds to a running client arrives as a
netmap delta rather than a full netmap. The delta path never re-resolved
the exit node prefs. An exit node selected by IP before it was in the
netmap stayed unresolved, and an auto exit node stayed on the blackhole
route, until tailscaled restarted or a full netmap arrived.

Re-resolve the exit node in UpdateNetmapDelta when the delta can change
the result. Any upserted peer qualifies while an ExitNodeIP is set. An
exit node being upserted or coming online qualifies while an auto exit
node is unresolved. The selected auto exit node going offline, losing its
exit routes, or being removed qualifies once one is selected. The last
case replaces the separate offline check, so the exit node is resolved
once per delta. The auto exit node check walks every peer, so it only
runs in those cases.

On the delta path, the resolved prefs ride in the same Notify as the peer
changes, sent while b.mu is held. resolveExitNodeLocked no longer sends a
Notify; its callers do. The full-netmap path still sends the prefs in a
separate Notify after the netmap.

Fixes #22012
Updates #22206

Signed-off-by: Brendan Creane <bcreane@gmail.com>
This commit is contained in:
Brendan Creane authored and GitHub committed 2026-11-05 16:28:01 -08:00
1 parent 8aa18b518f
commit e906e6934d
2 files changed
+366 -40

No files matched your search

+125 -40
View File
@@ -2194,7 +2194,9 @@ func (b *LocalBackend) setControlClientStatusLocked(c controlclient.Client, st c
//
// Otherwise, it might briefly show the exit node as offline and display a warning,
// if the node wasn't online or wasn't advertising default routes in the previous netmap.
b.refreshExitNodeLocked()
if b.refreshExitNodeLocked() {
b.sendLocked(ipn.Notify{Prefs: new(b.pm.CurrentPrefs())})
}
}
if st.URL != "" {
b.logf("Received auth URL: %.20v...", st.URL)
@@ -2525,16 +2527,18 @@ var (
func (b *LocalBackend) UpdateNetmapDelta(muts []netmap.NodeMutation) (handled bool) {
defer b.CheckDeadlocks()()
var notify *ipn.Notify // non-nil if we need to send a Notify
defer func() {
if notify != nil {
b.send(*notify)
}
}()
b.mu.Lock()
defer b.mu.Unlock()
var notify *ipn.Notify // non-nil if we need to send a Notify
defer func() {
// Sent while b.mu is still held, so it reflects the state this
// delta produced and nothing newer.
if notify != nil {
b.sendLocked(*notify)
}
}()
cn := b.currentNode()
// Filter the mutations through tailnet lock before applying them.
// Unsigned (or invalidly-signed) peers arriving via PeersChanged
@@ -2608,6 +2612,25 @@ func (b *LocalBackend) UpdateNetmapDelta(muts []netmap.NodeMutation) (handled bo
b.e.MarkDevicePeerForHandshake(k)
}
// This delta can change which exit node the prefs resolve to. An
// ExitNodeIP with no matching peer stays unresolved, and so does an
// AutoExitNode while no exit node is reachable. An unresolved exit
// node keeps traffic blackholed until it is resolved again. A selected
// auto exit node can also go offline or be removed. The full-netmap
// path resolves the exit node in
// [LocalBackend.setControlClientStatusLocked]. Resolve it here too,
// before the reconfig below, so the routes are installed once.
if b.exitNodeDeltaNeedsResolveLocked(muts, deltaRes.RemovedPeers) && b.resolveExitNodeLocked() {
// Deliver the new prefs in the same Notify as the peer changes
// below, so a GUI never sees prefs select a peer it has not been
// told about.
if notify == nil {
notify = &ipn.Notify{}
}
notify.Prefs = new(b.pm.CurrentPrefs())
needsAuthReconfig = true
}
// Force a full authReconfig + SetSelfNode on any peer add or
// remove. The WireGuard device itself no longer depends on this:
// the SyncDevicePeer calls above keep its peer set delta-correct,
@@ -2628,25 +2651,6 @@ func (b *LocalBackend) UpdateNetmapDelta(muts []netmap.NodeMutation) (handled bo
b.authReconfigLocked()
}
// If auto exit nodes are enabled and our exit node went offline,
// we need to schedule picking a new one.
// TODO(nickkhyl): move the auto exit node logic to a feature package.
if prefs := b.pm.CurrentPrefs(); prefs.AutoExitNode().IsSet() {
exitNodeID := prefs.ExitNodeID()
for _, m := range muts {
mo, ok := m.(netmap.NodeMutationOnline)
if !ok || mo.Online {
continue
}
n, ok := cn.NodeByID(m.NodeIDBeingMutated())
if !ok || n.StableID() != exitNodeID {
continue
}
b.refreshExitNodeLocked()
break
}
}
// TODO(sfllaw): If [buildfeatures.HasRouteCheck] is enabled,
// a probe may be triggered for an updated routecheck reachability report,
// which should influence which exit nodes are considered valid to suggest.
@@ -2685,7 +2689,9 @@ func (b *LocalBackend) UpdateNetmapDelta(muts []netmap.NodeMutation) (handled bo
// into full Nodes for watchers that asked for PeerChanges but not
// PeerPatches).
if peersUpsertedOrRemoved || mutationsAreWorthyOfTellingIPNBus(muts) {
notify = &ipn.Notify{}
if notify == nil {
notify = &ipn.Notify{}
}
for _, m := range muts {
switch m := m.(type) {
case netmap.NodeMutationUpsert:
@@ -2699,7 +2705,7 @@ func (b *LocalBackend) UpdateNetmapDelta(muts []netmap.NodeMutation) (handled bo
} else if !ok {
b.logf("[unexpected] got mutations worthy of telling IPN bus but failed to convert to peer changes")
}
} else if testenv.InTest() {
} else if testenv.InTest() && notify == nil {
// In tests, send an empty Notify as a wake-up so end-to-end
// integration tests in another repo can check on the status of
// LocalBackend after processing deltas.
@@ -2708,6 +2714,74 @@ func (b *LocalBackend) UpdateNetmapDelta(muts []netmap.NodeMutation) (handled bo
return true
}
// exitNodeDeltaNeedsResolveLocked reports whether a delta can change the
// result of [LocalBackend.resolveExitNodeInPrefsLocked]. muts are the
// mutations that were applied, and removed are the stable IDs of the peers
// they removed.
//
// An ExitNodeIP is resolved by one map lookup, so any upserted peer qualifies
// while an ExitNodeIP is set. Resolving an AutoExitNode walks every peer, so
// that only qualifies when the delta affects the selection. While no exit
// node has been selected yet, an exit node being upserted or coming online
// qualifies. Once one is selected, that exit node going offline, losing its
// exit routes, or being removed qualifies.
//
// TODO(nickkhyl): move the auto exit node logic to a feature package.
//
// b.mu must be held.
func (b *LocalBackend) exitNodeDeltaNeedsResolveLocked(muts []netmap.NodeMutation, removed []tailcfg.StableNodeID) bool {
if !buildfeatures.HasUseExitNode {
return false
}
cn := b.currentNode()
if cn.NetMap() == nil {
return false
}
prefs := b.pm.CurrentPrefs()
byIP := prefs.ExitNodeIP().IsValid()
auto := prefs.AutoExitNode().IsSet()
if !byIP && !auto {
return false
}
exitNodeID := prefs.ExitNodeID()
if auto && slices.Contains(removed, exitNodeID) {
return true
}
// The delta has already been applied, so the peer set is current. An
// auto exit node whose selected peer is not in it counts as unresolved,
// whether the prefs hold [ipn.UnresolvedExitNodeID] or a stale node ID.
_, selectedPresent := cn.PeerByStableID(exitNodeID)
autoUnresolved := auto && !selectedPresent
autoSelected := auto && selectedPresent
for _, m := range muts {
switch m := m.(type) {
case netmap.NodeMutationUpsert:
if byIP || (autoUnresolved && tsaddr.ContainsExitRoutes(m.Node.AllowedIPs())) {
return true
}
if autoSelected && m.Node.StableID() == exitNodeID &&
(!m.Node.Online().Get() || !tsaddr.ContainsExitRoutes(m.Node.AllowedIPs())) {
return true
}
case netmap.NodeMutationOnline:
if !auto {
continue
}
n, ok := cn.NodeByID(m.NodeIDBeingMutated())
if !ok {
continue
}
if autoUnresolved && m.Online && tsaddr.ContainsExitRoutes(n.AllowedIPs()) {
return true
}
if autoSelected && !m.Online && n.StableID() == exitNodeID {
return true
}
}
}
return false
}
func netmapDeltaNeedsAuthReconfig(cn *nodeBackend, muts []netmap.NodeMutation) bool {
for _, m := range muts {
switch m := m.(type) {
@@ -7358,25 +7432,33 @@ func (b *LocalBackend) RefreshExitNode() {
}
b.mu.Lock()
defer b.mu.Unlock()
b.refreshExitNodeLocked()
if b.refreshExitNodeLocked() {
b.sendLocked(ipn.Notify{Prefs: new(b.pm.CurrentPrefs())})
}
}
// refreshExitNodeLocked is like RefreshExitNode but requires b.mu be held.
func (b *LocalBackend) refreshExitNodeLocked() {
// If it reports true, the caller must send an [ipn.Notify] carrying
// b.pm.CurrentPrefs().
func (b *LocalBackend) refreshExitNodeLocked() (changed bool) {
syncs.RequiresMutex(&b.mu)
if b.resolveExitNodeLocked() {
b.authReconfigLocked()
if !b.resolveExitNodeLocked() {
return false
}
b.authReconfigLocked()
return true
}
// resolveExitNodeLocked determines which exit node to use based on the current prefs
// and netmap. It updates the exit node ID in the prefs if needed, updates the
// exit node ID in the hostinfo if needed, sends a notification to clients, and
// returns true if the exit node has changed.
// exit node ID in the hostinfo if needed, and reports whether the current
// prefs changed as a result.
//
// It is the caller's responsibility to reconfigure routes and actually
// start using the selected exit node, if needed.
// If it reports true, the caller must send an [ipn.Notify] carrying
// b.pm.CurrentPrefs(), reconfigure routes, and actually start using the
// selected exit node, if needed. It reports false if the prefs could not
// be saved, so the caller acts only on prefs that are in effect.
//
// b.mu must be held.
func (b *LocalBackend) resolveExitNodeLocked() (changed bool) {
@@ -7387,9 +7469,10 @@ func (b *LocalBackend) resolveExitNodeLocked() (changed bool) {
}
nm := b.currentNode().NetMap()
prefs := b.pm.CurrentPrefs().AsStruct()
oldPrefs := b.pm.CurrentPrefs()
prefs := oldPrefs.AsStruct()
if !b.resolveExitNodeInPrefsLocked(prefs) {
return
return false
}
if err := b.pm.SetPrefs(prefs.View(), ipn.NetworkProfile{
@@ -7399,6 +7482,9 @@ func (b *LocalBackend) resolveExitNodeLocked() (changed bool) {
}); err != nil {
b.logf("failed to save exit node changes: %v", err)
}
if oldPrefs.Equals(b.pm.CurrentPrefs()) {
return false
}
// Send the resolved exit node to control via [tailcfg.Hostinfo].
// [LocalBackend.applyPrefsToHostinfoLocked] usually sets the Hostinfo,
@@ -7413,7 +7499,6 @@ func (b *LocalBackend) resolveExitNodeLocked() (changed bool) {
b.goTracker.Go(b.doSetHostinfoFilterServices)
}
b.sendToLocked(ipn.Notify{Prefs: new(prefs.View())}, allClients)
return true
}
+241
View File
@@ -2621,6 +2621,247 @@ func TestSetControlClientStatusSendsFullNetmapAsPeerChanges(t *testing.T) {
nw.check()
}
// TestExitNodeIPResolvedOnDeltaUpsert checks that an exit node selected by
// IP before it was in the netmap is resolved to a node ID when the node
// arrives as a delta upsert, not only on the next full netmap.
//
// See https://github.com/tailscale/tailscale/issues/22012.
func TestExitNodeIPResolvedOnDeltaUpsert(t *testing.T) {
self := makePeer(1, withName("self"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.1/32")))
exitNode := makeExitNode(2, withName("exit"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.2/32")))
other := makePeer(10, withName("other"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.10/32")))
b := newTestLocalBackend(t)
b.ForTest().SetPrefs(&ipn.Prefs{
ControlURL: "https://localhost:1/",
ExitNodeIP: exitNode.Addresses().At(0).Addr(),
})
// A full netmap that does not contain the exit node leaves the IP unresolved.
b.SetControlClientStatus(b.cc, controlclient.Status{NetMap: buildNetmapWithPeers(self, other), LoggedIn: true})
if p := b.Prefs(); p.ExitNodeID() != "" || !p.ExitNodeIP().IsValid() {
t.Fatalf("after netmap without exit node: ExitNodeID=%q ExitNodeIP=%v; want unresolved", p.ExitNodeID(), p.ExitNodeIP())
}
// A peer that is not the exit node does not resolve it.
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: makePeer(11, withAddresses(netip.MustParsePrefix("100.64.1.11/32")))}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if p := b.Prefs(); p.ExitNodeID() != "" || !p.ExitNodeIP().IsValid() {
t.Fatalf("after unrelated upsert: ExitNodeID=%q ExitNodeIP=%v; want unresolved", p.ExitNodeID(), p.ExitNodeIP())
}
// The exit node arrives by delta and is resolved. Watchers must learn
// about the peer and the prefs that select it in the same notification.
nw := newNotificationWatcher(t, b, ipnauth.Self)
nw.watch(ipn.NotifyPeerChanges|ipn.NotifyNoNetMap, []wantedNotification{{
name: "exit node peer change with prefs selecting it",
cond: func(_ testing.TB, _ ipnauth.Actor, n *ipn.Notify) bool {
hasPeer := slices.ContainsFunc(n.PeersChanged, func(p *tailcfg.Node) bool { return p.ID == exitNode.ID() })
hasPrefs := n.Prefs != nil && n.Prefs.Valid() && n.Prefs.ExitNodeID() == exitNode.StableID()
return hasPeer && hasPrefs
},
}})
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: exitNode}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
nw.check()
p := b.Prefs()
if p.ExitNodeID() != exitNode.StableID() {
t.Errorf("after delta upsert: ExitNodeID = %q, want %q", p.ExitNodeID(), exitNode.StableID())
}
if p.ExitNodeIP().IsValid() {
t.Errorf("after delta upsert: ExitNodeIP = %v, want cleared", p.ExitNodeIP())
}
if got := b.hostinfo.ExitNodeID; got != exitNode.StableID() {
t.Errorf("after delta upsert: hostinfo.ExitNodeID = %q, want %q", got, exitNode.StableID())
}
}
// TestAutoExitNodeResolvedOnDeltaUpsert checks that an auto exit node that
// could not be resolved, because no exit node was in the netmap, is selected
// when the first exit node arrives as a delta upsert.
func TestAutoExitNodeResolvedOnDeltaUpsert(t *testing.T) {
self := makePeer(1, withName("self"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.1/32")))
exitNode := makeExitNode(2, withName("exit"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.2/32")))
other := makePeer(10, withName("other"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.10/32")))
b := newTestLocalBackend(t)
b.ForTest().SetPrefs(&ipn.Prefs{
ControlURL: "https://localhost:1/",
AutoExitNode: ipn.AnyExitNode,
})
nm := buildNetmapWithPeers(self, other)
b.MagicConn().AddNetcheckReportForTest(nm.DERPMap, &netcheck.Report{
RegionLatency: map[tailcfg.DERPRegionID]time.Duration{1: 5 * time.Millisecond},
PreferredDERP: 1,
}, time.Now())
b.SetControlClientStatus(b.cc, controlclient.Status{NetMap: nm, LoggedIn: true})
if p := b.Prefs(); p.ExitNodeID() != ipn.UnresolvedExitNodeID {
t.Fatalf("after netmap without exit nodes: ExitNodeID=%q; want %q", p.ExitNodeID(), ipn.UnresolvedExitNodeID)
}
// A peer that is not an exit node leaves the blackhole in place.
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: makePeer(11, withAddresses(netip.MustParsePrefix("100.64.1.11/32")))}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if p := b.Prefs(); p.ExitNodeID() != ipn.UnresolvedExitNodeID {
t.Fatalf("after unrelated upsert: ExitNodeID=%q; want %q", p.ExitNodeID(), ipn.UnresolvedExitNodeID)
}
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: exitNode}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if p := b.Prefs(); p.ExitNodeID() != exitNode.StableID() {
t.Errorf("after delta upsert: ExitNodeID = %q, want %q", p.ExitNodeID(), exitNode.StableID())
}
if got := b.hostinfo.ExitNodeID; got != exitNode.StableID() {
t.Errorf("after delta upsert: hostinfo.ExitNodeID = %q, want %q", got, exitNode.StableID())
}
}
// TestAutoExitNodeResolvedOnDeltaOnline checks that an auto exit node that
// could not be resolved, because every exit node in the netmap was offline,
// is selected when an exit node comes online by delta patch.
func TestAutoExitNodeResolvedOnDeltaOnline(t *testing.T) {
self := makePeer(1, withName("self"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.1/32")))
exitNode := makeExitNode(2, withName("exit"), withDERP(1), withOnline(false), withAddresses(netip.MustParsePrefix("100.64.1.2/32")))
b := newTestLocalBackend(t)
b.ForTest().SetPrefs(&ipn.Prefs{
ControlURL: "https://localhost:1/",
AutoExitNode: ipn.AnyExitNode,
})
nm := buildNetmapWithPeers(self, exitNode)
b.MagicConn().AddNetcheckReportForTest(nm.DERPMap, &netcheck.Report{
RegionLatency: map[tailcfg.DERPRegionID]time.Duration{1: 5 * time.Millisecond},
PreferredDERP: 1,
}, time.Now())
b.SetControlClientStatus(b.cc, controlclient.Status{NetMap: nm, LoggedIn: true})
if p := b.Prefs(); p.ExitNodeID() != ipn.UnresolvedExitNodeID {
t.Fatalf("after netmap with only an offline exit node: ExitNodeID=%q; want %q", p.ExitNodeID(), ipn.UnresolvedExitNodeID)
}
muts, ok := netmap.MutationsFromMapResponse(&tailcfg.MapResponse{
PeersChangedPatch: []*tailcfg.PeerChange{{NodeID: exitNode.ID(), Online: new(true)}},
}, time.Now())
if !ok {
t.Fatal("MutationsFromMapResponse failed")
}
if !b.UpdateNetmapDelta(muts) {
t.Fatal("UpdateNetmapDelta returned false")
}
if p := b.Prefs(); p.ExitNodeID() != exitNode.StableID() {
t.Errorf("after online patch: ExitNodeID = %q, want %q", p.ExitNodeID(), exitNode.StableID())
}
if got := b.hostinfo.ExitNodeID; got != exitNode.StableID() {
t.Errorf("after online patch: hostinfo.ExitNodeID = %q, want %q", got, exitNode.StableID())
}
}
// TestAutoExitNodeReselectedOnDeltaRemove checks that an auto exit node is
// reselected when the selected exit node is removed by delta.
func TestAutoExitNodeReselectedOnDeltaRemove(t *testing.T) {
self := makePeer(1, withName("self"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.1/32")))
// Both exit nodes are in the preferred region, so the previous suggestion
// is kept while it exists.
exitNode2 := makeExitNode(2, withName("exit2"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.2/32")))
exitNode3 := makeExitNode(3, withName("exit3"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.3/32")))
b := newTestLocalBackend(t)
b.ForTest().SetPrefs(&ipn.Prefs{
ControlURL: "https://localhost:1/",
AutoExitNode: ipn.AnyExitNode,
})
nm := buildNetmapWithPeers(self, exitNode2, exitNode3)
b.MagicConn().AddNetcheckReportForTest(nm.DERPMap, &netcheck.Report{
RegionLatency: map[tailcfg.DERPRegionID]time.Duration{1: 5 * time.Millisecond},
PreferredDERP: 1,
}, time.Now())
b.SetControlClientStatus(b.cc, controlclient.Status{NetMap: nm, LoggedIn: true})
selected := b.Prefs().ExitNodeID()
if selected != exitNode2.StableID() && selected != exitNode3.StableID() {
t.Fatalf("after netmap: ExitNodeID=%q; want one of the exit nodes", selected)
}
removed, remaining := exitNode2, exitNode3
if selected == exitNode3.StableID() {
removed, remaining = exitNode3, exitNode2
}
// Removing the other exit node leaves the selection alone.
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.MakeNodeMutationRemove(remaining.ID())}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if got := b.Prefs().ExitNodeID(); got != selected {
t.Fatalf("after removing the other exit node: ExitNodeID=%q; want %q", got, selected)
}
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: remaining}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
// Removing the selected exit node switches to the remaining one.
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.MakeNodeMutationRemove(removed.ID())}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if got := b.Prefs().ExitNodeID(); got != remaining.StableID() {
t.Errorf("after removing the selected exit node: ExitNodeID=%q; want %q", got, remaining.StableID())
}
if got := b.hostinfo.ExitNodeID; got != remaining.StableID() {
t.Errorf("after removing the selected exit node: hostinfo.ExitNodeID = %q, want %q", got, remaining.StableID())
}
}
// TestAutoExitNodeReselectedOnDeltaUpsertOffline checks that an auto exit
// node is reselected when an upsert of the selected exit node marks it
// offline.
func TestAutoExitNodeReselectedOnDeltaUpsertOffline(t *testing.T) {
self := makePeer(1, withName("self"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.1/32")))
exitNode2 := makeExitNode(2, withName("exit2"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.2/32")))
exitNode3 := makeExitNode(3, withName("exit3"), withDERP(1), withAddresses(netip.MustParsePrefix("100.64.1.3/32")))
b := newTestLocalBackend(t)
b.ForTest().SetPrefs(&ipn.Prefs{
ControlURL: "https://localhost:1/",
AutoExitNode: ipn.AnyExitNode,
})
nm := buildNetmapWithPeers(self, exitNode2, exitNode3)
b.MagicConn().AddNetcheckReportForTest(nm.DERPMap, &netcheck.Report{
RegionLatency: map[tailcfg.DERPRegionID]time.Duration{1: 5 * time.Millisecond},
PreferredDERP: 1,
}, time.Now())
b.SetControlClientStatus(b.cc, controlclient.Status{NetMap: nm, LoggedIn: true})
selected := b.Prefs().ExitNodeID()
if selected != exitNode2.StableID() && selected != exitNode3.StableID() {
t.Fatalf("after netmap: ExitNodeID=%q; want one of the exit nodes", selected)
}
selectedNode, other := exitNode2, exitNode3
if selected == exitNode3.StableID() {
selectedNode, other = exitNode3, exitNode2
}
// An upsert of the other exit node leaves the selection alone.
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: other}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if got := b.Prefs().ExitNodeID(); got != selected {
t.Fatalf("after upsert of the other exit node: ExitNodeID=%q; want %q", got, selected)
}
// An upsert that marks the selected exit node offline switches away from it.
offline := selectedNode.AsStruct()
offline.Online = new(false)
if !b.UpdateNetmapDelta([]netmap.NodeMutation{netmap.NodeMutationUpsert{Node: offline.View()}}) {
t.Fatal("UpdateNetmapDelta returned false")
}
if got := b.Prefs().ExitNodeID(); got != other.StableID() {
t.Errorf("after upsert marking the selected exit node offline: ExitNodeID=%q; want %q", got, other.StableID())
}
}
// sendFullNetmap delivers a full netmap from control, as after a
// MapResponse that can't be applied as a delta or on a new map session.
func sendFullNetmap(b *LocalBackend, peers ...tailcfg.NodeView) {