From 18c7c3981a469aa2235c4d24b4d8098eb579248d Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Tue, 22 Nov 2022 04:11:44 +0500 Subject: [PATCH] ipn/ipnlocal: call checkPrefs in Start too We were not calling checkPrefs on `opts.*Prefs` in (*LocalBackend).Start(). Updates #713 Signed-off-by: Maisem Ali --- ipn/ipnlocal/local.go | 11 +++++++++++ wgengine/netstack/netstack_test.go | 15 ++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 7d1f98b3e..c3fe5babc 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -1122,6 +1122,17 @@ func (b *LocalBackend) Start(opts ipn.Options) error { } b.mu.Lock() + if opts.UpdatePrefs != nil { + if err := b.checkPrefsLocked(opts.UpdatePrefs); err != nil { + b.mu.Unlock() + return err + } + } else if opts.LegacyMigrationPrefs != nil { + if err := b.checkPrefsLocked(opts.LegacyMigrationPrefs); err != nil { + b.mu.Unlock() + return err + } + } profileID := b.pm.CurrentProfile().ID // The iOS client sends a "Start" whenever its UI screen comes diff --git a/wgengine/netstack/netstack_test.go b/wgengine/netstack/netstack_test.go index cc6403eea..d0b2c67c4 100644 --- a/wgengine/netstack/netstack_test.go +++ b/wgengine/netstack/netstack_test.go @@ -268,10 +268,11 @@ func looksLikeATailscaleSelfAddress(addr netip.Addr) bool { func TestShouldProcessInbound(t *testing.T) { testCases := []struct { - name string - pkt *packet.Parsed - setup func(*Impl) - want bool + name string + pkt *packet.Parsed + setup func(*Impl) + want bool + runOnGOOS string }{ { name: "ipv6-via", @@ -349,7 +350,8 @@ func TestShouldProcessInbound(t *testing.T) { return addr.String() == "100.101.102.104" // Dst, above }) }, - want: true, + want: true, + runOnGOOS: "linux", }, { name: "tailscale-ssh-disabled", @@ -443,6 +445,9 @@ func TestShouldProcessInbound(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + if tc.runOnGOOS != "" && runtime.GOOS != tc.runOnGOOS { + t.Skipf("skipping on GOOS=%v", runtime.GOOS) + } impl := makeNetstack(t, func(i *Impl) { defer t.Logf("netstack setup finished")