net/netutil: parse IP forwarding val as int, not bool (#8455)

This commit updates our IP forwarding parsing logic to allow the less
common but still valid value of `2` to be parsed as `true`, which fixes
an error some users encountered.

Fixes #8375

Signed-off-by: Ross Zurowski <ross@rosszurowski.com>
pull/8471/head
Ross Zurowski 11 months ago committed by GitHub
parent a874f1afd8
commit 832f1028c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -212,9 +212,16 @@ func ipForwardingEnabledLinux(p protocol, iface string) (bool, error) {
}
return false, err
}
on, err := strconv.ParseBool(string(bytes.TrimSpace(bs)))
val, err := strconv.ParseInt(string(bytes.TrimSpace(bs)), 10, 32)
if err != nil {
return false, fmt.Errorf("couldn't parse %s: %w", k, err)
}
// 0 = disabled, 1 = enabled, 2 = enabled (but uncommon)
// https://github.com/tailscale/tailscale/issues/8375
if val < 0 || val > 2 {
return false, fmt.Errorf("unexpected value %d for %s", val, k)
}
on := val == 1 || val == 2
return on, nil
}

Loading…
Cancel
Save