mirror of
https://github.com/tailscale/tailscale.git
synced 2026-10-30 15:09:29 -04:00
Windows socket setup enumerates adapters and the routing table through GetWindowsDefault for every netns socket. These calls can be expensive, particularly on systems where security software adds syscall latency. Cache nonzero default interface indices per monitor and address family, and use them from netns controlC. Invalidate on native route, address, and IP interface change notifications. Coalesce concurrent lookups and retry results invalidated during lookup. Bound lookup and wait attempts; once the budget is exhausted, fall back to a single uncached lookup rather than failing socket setup, erring toward a possibly stale interface index over no socket at all. Perform fresh lookups for zero indices and errors, and retain the existing unbound-socket fallback for a fresh zero result. Use uncached lookups after monitor shutdown or when interface-change notification registration fails. Test cache reuse, independent address families, notification invalidation, concurrent fills, invalidation during lookup, route restoration after a zero result, churn and wait-budget fallbacks, and shutdown. Fixes #21885 Signed-off-by: James Tucker <james@tailscale.com>