mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-22 12:42:42 +09:00
A Magic IP gets its address assignment when the DNS response is rewritten, but the Transit IP it maps to only becomes usable later: handleAddressAssignment registers it with the connector over PeerAPI, and only then does addTransitIPForConnector put it in byConnKey, where extraWireGuardAllowedIPs picks it up and hands it to WireGuard as an allowed IP for that peer. Until then, transitIPForMagicIP would happily return the Transit IP, the datapath would DNAT to it, and WireGuard would drop the packet because no peer claims the address. The client application saw a black hole and hung. That window stays open indefinitely when the registration never lands: a failed PeerAPI request, a full assignment queue, or a reset that clears byConnKey. transitIPForMagicIP now checks that the Transit IP is registered under its connector's node key, and returns the new ErrTransitIPNotRoutable if it isn't. The datapath treats that like an unknown Magic IP and injects an ICMP host unreachable, so the application fails fast instead of hanging. Fixes https://github.com/tailscale/corp/issues/50405 Change-Id: Id232e27063f27278e65279d9b1adad5d67d3b6ef Signed-off-by: Mazdak Nasab <mazdak.nasab@gmail.com>