mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-20 08:41:19 -08:00
The cleanup returned by flowCreated decremented activeFlowCount on every call, and its documented contract pushed the burden of calling it exactly once onto the datapath. A caller that lost track and ran a cleanup twice would undercount the flows still forwarding over the assignment, letting popExpired reclaim both of its addresses back to the pools mid-connection, or drive the count to -1, which can never again satisfy popExpired's zero-flow test and so pins the assignment in the expiry heap and leaks both addresses for the life of the process. The cleanup now releases its hold at most once, guarded by a bool read and written under c.mu alongside the decrement it protects. Repeat calls are no-ops. The Conn25Datapath docs no longer ask callers to guarantee this. No such double-call is reachable through FlowTable today: removeFlowLocked deletes both cache entries, so NewFlow's second lookup misses, and the capacity eviction takes lru.Back(), never the flow just pushed to the front. This removes the class rather than a live bug. Updates https://github.com/tailscale/corp/issues/50760 Change-Id: I1888f36eb8fdec9b219ccfd2d290dc4eb19c55a0 Signed-off-by: Mazdak Nasab <[email protected]>