From ac84eb490054032d519df69d6a855abf6fb36a8c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 8 Jul 2026 23:24:06 +0000 Subject: [PATCH] ipn/ipnlocal: pass self node view to reconfigAppConnectorLocked The netmap.NetworkMap type is deprecated and going away, and reconfigAppConnectorLocked only needed its SelfNode field anyway. Take a tailcfg.NodeView instead and check its validity in place of the old nil netmap check. Updates #12542 Change-Id: Id617845b67416404500cca438ce4ac0372cd8a8e Signed-off-by: Brad Fitzpatrick --- ipn/ipnlocal/local.go | 12 ++++++------ ipn/ipnlocal/local_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 50a49d04b..dfbfba191 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -5899,9 +5899,9 @@ func (b *LocalBackend) blockEngineUpdatesLocked(block bool) { } // reconfigAppConnectorLocked updates the app connector state based on the -// current network map and preferences. +// self node and preferences. // b.mu must be held. -func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs ipn.PrefsView) { +func (b *LocalBackend) reconfigAppConnectorLocked(selfNode tailcfg.NodeView, prefs ipn.PrefsView) { if !buildfeatures.HasAppConnectors { return } @@ -5935,11 +5935,11 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i HasStoredRoutes: shouldStoreRoutes, }) } - if nm == nil { + if !selfNode.Valid() { return } - attrs, err := tailcfg.UnmarshalNodeCapViewJSON[appctype.AppConnectorAttr](nm.SelfNode.CapMap(), appConnectorCapName) + attrs, err := tailcfg.UnmarshalNodeCapViewJSON[appctype.AppConnectorAttr](selfNode.CapMap(), appConnectorCapName) if err != nil { b.logf("[unexpected] error parsing app connector mapcap: %v", err) return @@ -5947,7 +5947,7 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i // Geometric cost, assumes that the number of advertised tags is small selfHasTag := func(attrTags []string) bool { - return nm.SelfNode.Tags().ContainsFunc(func(tag string) bool { + return selfNode.Tags().ContainsFunc(func(tag string) bool { return slices.Contains(attrTags, tag) }) } @@ -6054,7 +6054,7 @@ func (b *LocalBackend) authReconfigLocked() { dohURL, dohURLOK := cn.exitNodeCanProxyDNS(prefs.ExitNodeID()) dcfg := cn.dnsConfigForNetmap(prefs, b.keyExpired, version.OS()) // If the current node is an app connector, ensure the app connector machine is started - b.reconfigAppConnectorLocked(nm, prefs) + b.reconfigAppConnectorLocked(nm.SelfNode, prefs) if !prefs.WantRunning() { b.logf("[v1] authReconfig: skipping because !WantRunning.") diff --git a/ipn/ipnlocal/local_test.go b/ipn/ipnlocal/local_test.go index 757b53349..fc08c7c7b 100644 --- a/ipn/ipnlocal/local_test.go +++ b/ipn/ipnlocal/local_test.go @@ -3497,7 +3497,7 @@ func TestCoveredRouteRangeNoDefault(t *testing.T) { func TestReconfigureAppConnector(t *testing.T) { b := newTestBackend(t) - b.reconfigAppConnectorLocked(b.NetMap(), b.pm.prefs) + b.reconfigAppConnectorLocked(b.currentNode().Self(), b.pm.prefs) if b.appConnector != nil { t.Fatal("unexpected app connector") } @@ -3510,7 +3510,7 @@ func TestReconfigureAppConnector(t *testing.T) { }, AppConnectorSet: true, }) - b.reconfigAppConnectorLocked(b.NetMap(), b.pm.prefs) + b.reconfigAppConnectorLocked(b.currentNode().Self(), b.pm.prefs) if b.appConnector == nil { t.Fatal("expected app connector") } @@ -3533,7 +3533,7 @@ func TestReconfigureAppConnector(t *testing.T) { b.currentNode().SetNetMap(nm) - b.reconfigAppConnectorLocked(b.NetMap(), b.pm.prefs) + b.reconfigAppConnectorLocked(b.currentNode().Self(), b.pm.prefs) b.appConnector.Wait(context.Background()) want := []string{"example.com"} @@ -3553,7 +3553,7 @@ func TestReconfigureAppConnector(t *testing.T) { }, AppConnectorSet: true, }) - b.reconfigAppConnectorLocked(b.NetMap(), b.pm.prefs) + b.reconfigAppConnectorLocked(b.currentNode().Self(), b.pm.prefs) if b.appConnector != nil { t.Fatal("expected no app connector") } @@ -3585,7 +3585,7 @@ func TestBackfillAppConnectorRoutes(t *testing.T) { }); err != nil { t.Fatal(err) } - b.reconfigAppConnectorLocked(b.NetMap(), b.pm.prefs) + b.reconfigAppConnectorLocked(b.currentNode().Self(), b.pm.prefs) // Smoke check that AdvertiseRoutes doesn't have the test IP. ip := netip.MustParseAddr("1.2.3.4") @@ -3606,7 +3606,7 @@ func TestBackfillAppConnectorRoutes(t *testing.T) { // Mimic b.authReconfigure for the app connector bits. b.mu.Lock() - b.reconfigAppConnectorLocked(b.NetMap(), b.pm.prefs) + b.reconfigAppConnectorLocked(b.currentNode().Self(), b.pm.prefs) b.mu.Unlock() b.readvertiseAppConnectorRoutes()