state: classify map requests before broadcasting

Each request is reduced to the narrowest change it justifies, so a
keepalive or endpoint bump no longer resends the whole node to peers.

Updates #3417

0.29 pins an older tailscale where Hostinfo.NetInfo.PreferredDERP is an int,
so the DERPRegionID types are int here.

(cherry picked from commit 59f3ff12a7)
This commit is contained in:
Kristoffer Dalby
2026-09-10 11:15:07 +00:00
parent b8da1c2d6f
commit 8973347d22
6 changed files with 1240 additions and 216 deletions
+2 -3
View File
@@ -675,9 +675,8 @@ func (node *Node) MarshalZerologObject(e *zerolog.Event) {
// PeerChangeFromMapRequest takes a [tailcfg.MapRequest] and compares it to the node
// to produce a [tailcfg.PeerChange] struct that can be used to updated the node and
// inform peers about smaller changes to the node.
// When a field is added to this function, remember to also add it to:
// - [Node.ApplyPeerChange]
// - logTracePeerChange in poll.go.
// When a field is added to this function, also add it to
// [Node.ApplyPeerChange].
func (node *Node) PeerChangeFromMapRequest(req tailcfg.MapRequest) tailcfg.PeerChange {
ret := tailcfg.PeerChange{
NodeID: tailcfg.NodeID(node.ID), //nolint:gosec // NodeID is bounded