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 <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-07-09 15:04:59 -07:00
committed by Brad Fitzpatrick
parent ca9f6971e5
commit ac84eb4900
2 changed files with 12 additions and 12 deletions
+6 -6
View File
@@ -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.")
+6 -6
View File
@@ -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()