From 1fe073098ce442faea57de948dc02626cc9f173d Mon Sep 17 00:00:00 2001 From: Shaw Drastin <168159404+showier-drastic@users.noreply.github.com> Date: Wed, 1 May 2024 01:42:49 +0800 Subject: [PATCH] Reset dial plan when switching profile (#11933) When switching profile, the server URL can change (e.g. because of switching to a self-hosted headscale instance). If it is not reset here, dial plans returned by old server (e.g. tailscale control server) will be used to connect to new server (e.g. self-hosted headscale server), and the register request will be blocked by it until timeout, leading to very slow profile switches. Updates #11938 11938 Signed-off-by: Shaw Drastin --- ipn/ipnlocal/local.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index c67c87c20..83b9426e7 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -5881,6 +5881,11 @@ func (b *LocalBackend) SwitchProfile(profile ipn.ProfileID) error { if err := b.pm.SwitchProfile(profile); err != nil { return err } + + // TODO: Check if serverUrl in the switched profile is actually changed; + // if not, then no need to reset dial plan + b.dialPlan.Store(nil) + return b.resetForProfileChangeLockedOnEntry(unlock) }