From d5d84f1a68dc9495ed7b91b4655a869268ac3cfd Mon Sep 17 00:00:00 2001 From: Jenny Zhang Date: Fri, 24 Nov 2023 14:21:23 -0500 Subject: [PATCH] cmd/tailscale: also warn about IP forwarding if using CLI set We warn users about IP forwarding being disabled when using `--avertise-routes` in `tailscale up`, this adds the same warnings to `tailscale set`. Updates tailscale/corp#9968 Signed-off-by: Jenny Zhang --- cmd/tailscale/cli/set.go | 1 + cmd/tailscale/cli/up.go | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cmd/tailscale/cli/set.go b/cmd/tailscale/cli/set.go index 8c8e04927..f908178a4 100644 --- a/cmd/tailscale/cli/set.go +++ b/cmd/tailscale/cli/set.go @@ -135,6 +135,7 @@ func runSet(ctx context.Context, args []string) (retErr error) { } } + warnOnAdvertiseRouts(ctx, &maskedPrefs.Prefs) var advertiseExitNodeSet, advertiseRoutesSet bool setFlagSet.Visit(func(f *flag.Flag) { updateMaskedPrefsFromUpOrSetFlag(maskedPrefs, f.Name) diff --git a/cmd/tailscale/cli/up.go b/cmd/tailscale/cli/up.go index 1706418b3..2fce3599e 100644 --- a/cmd/tailscale/cli/up.go +++ b/cmd/tailscale/cli/up.go @@ -437,18 +437,7 @@ func runUp(ctx context.Context, cmd string, args []string, upArgs upArgsT) (retE fatalf("%s", err) } - if len(prefs.AdvertiseRoutes) > 0 || prefs.AppConnector.Advertise { - // TODO(jwhited): compress CheckIPForwarding and CheckUDPGROForwarding - // into a single HTTP req. - if err := localClient.CheckIPForwarding(ctx); err != nil { - warnf("%v", err) - } - if runtime.GOOS == "linux" { - if err := localClient.CheckUDPGROForwarding(ctx); err != nil { - warnf("%v", err) - } - } - } + warnOnAdvertiseRouts(ctx, prefs) curPrefs, err := localClient.GetPrefs(ctx) if err != nil { @@ -1159,3 +1148,18 @@ func resolveAuthKey(ctx context.Context, v, tags string) (string, error) { } return authkey, nil } + +func warnOnAdvertiseRouts(ctx context.Context, prefs *ipn.Prefs) { + if len(prefs.AdvertiseRoutes) > 0 || prefs.AppConnector.Advertise { + // TODO(jwhited): compress CheckIPForwarding and CheckUDPGROForwarding + // into a single HTTP req. + if err := localClient.CheckIPForwarding(ctx); err != nil { + warnf("%v", err) + } + if runtime.GOOS == "linux" { + if err := localClient.CheckUDPGROForwarding(ctx); err != nil { + warnf("%v", err) + } + } + } +}