ipn/ipnlocal: add URL to IP forwarding error message

Updates #606

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2021-07-28 08:00:03 -07:00
parent f414a9cc01
commit 690ade4ee1

View File

@ -2743,17 +2743,18 @@ func (b *LocalBackend) CheckIPForwarding() error {
return nil return nil
} }
const suffix = "\nSubnet routes won't work without IP forwarding.\nSee https://tailscale.com/kb/1104/enable-ip-forwarding/"
for _, key := range keys { for _, key := range keys {
bs, err := exec.Command("sysctl", "-n", key).Output() bs, err := exec.Command("sysctl", "-n", key).Output()
if err != nil { if err != nil {
return fmt.Errorf("couldn't check %s (%v).\nSubnet routes won't work without IP forwarding.", key, err) return fmt.Errorf("couldn't check %s (%v)%s", key, err, suffix)
} }
on, err := strconv.ParseBool(string(bytes.TrimSpace(bs))) on, err := strconv.ParseBool(string(bytes.TrimSpace(bs)))
if err != nil { if err != nil {
return fmt.Errorf("couldn't parse %s (%v).\nSubnet routes won't work without IP forwarding.", key, err) return fmt.Errorf("couldn't parse %s (%v)%s.", key, err, suffix)
} }
if !on { if !on {
return fmt.Errorf("%s is disabled. Subnet routes won't work.", key) return fmt.Errorf("%s is disabled.%s", key, suffix)
} }
} }
return nil return nil