net/routemanager,ipn/ipnlocal: name the changed-allowed-IPs map type

The map[key.NodePublic][]netip.Prefix that flows from route manager
commits to WireGuard device syncs has subtle semantics (a nil value
means the peer was removed or no longer contributes any prefixes)
that were documented on routemanager.Result.AllowedIPs and then
re-documented, or not, at each signature that passed it along. Give
it a named type, PeersWithRouteChanges, and document the nil
semantics once on it.

Updates #12542

Change-Id: I2566361a5331eb11b2b70a5bcdb497cc20ee561d
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-07-14 19:57:59 -04:00
committed by Brad Fitzpatrick
parent f0ce89b715
commit 87c0d36942
3 changed files with 22 additions and 21 deletions
+7 -11
View File
@@ -918,10 +918,9 @@ type routePrefs struct {
// updateRouteManagerPrefs pushes p into the route manager.
//
// It returns the peers whose allowed source prefixes changed as a
// result (for example the old and new exit node when the selection
// changes), as described by [routemanager.Result.AllowedIPs].
// In particular, the value for a key will be nil when that peer was removed.
func (nb *nodeBackend) updateRouteManagerPrefs(p routePrefs) (changedAllowedIPs map[key.NodePublic][]netip.Prefix) {
// result, for example the old and new exit node when the selection
// changes.
func (nb *nodeBackend) updateRouteManagerPrefs(p routePrefs) routemanager.PeersWithRouteChanges {
nb.mu.Lock()
defer nb.mu.Unlock()
var exitID tailcfg.NodeID
@@ -950,8 +949,8 @@ func (nb *nodeBackend) updateRouteManagerPrefs(p routePrefs) (changedAllowedIPs
// public key.
//
// It returns the peers whose allowed source prefixes changed as a
// result, as described by [routemanager.Result.AllowedIPs].
func (nb *nodeBackend) updateRouteManagerExtras(fn func(key.NodePublic) views.Slice[netip.Prefix]) (changedAllowedIPs map[key.NodePublic][]netip.Prefix) {
// result.
func (nb *nodeBackend) updateRouteManagerExtras(fn func(key.NodePublic) views.Slice[netip.Prefix]) routemanager.PeersWithRouteChanges {
nb.mu.Lock()
defer nb.mu.Unlock()
var extras map[tailcfg.NodeID][]netip.Prefix
@@ -1010,11 +1009,8 @@ func (nb *nodeBackend) mergeUserProfiles(profiles map[tailcfg.UserID]tailcfg.Use
// delta mutations that the caller must propagate.
type netmapDeltaResult struct {
// ChangedAllowedIPs are the peers whose allowed source prefixes
// changed, as described by [routemanager.Result.AllowedIPs]; the
// caller syncs those peers to the WireGuard device. In
// particular, the value for a key will be nil when that peer was
// removed.
ChangedAllowedIPs map[key.NodePublic][]netip.Prefix
// changed; the caller syncs those peers to the WireGuard device.
ChangedAllowedIPs routemanager.PeersWithRouteChanges
// DiscoChanged is the set of peers whose disco key changed in a
// way that requires a WireGuard session reset (see