mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 14:57:49 +00:00
wgengine/netstack: fix netstack ping timeout on darwin
-W is milliseconds on darwin, not seconds, and empirically it's milliseconds after a 1 second base. Change-Id: I2520619e6699d9c505d9645ce4dfee4973555227 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
96f008cf87
commit
6be48dfcc6
@ -426,6 +426,11 @@ func (ns *Impl) userPing(dstIP netaddr.IP, pingResPkt []byte) {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
err = exec.Command("ping", "-n", "1", "-w", "3000", dstIP.String()).Run()
|
||||
case "darwin":
|
||||
// Note: 2000 ms is actually 1 second + 2,000
|
||||
// milliseconds extra for 3 seconds total.
|
||||
// See https://github.com/tailscale/tailscale/pull/3753 for details.
|
||||
err = exec.Command("ping", "-c", "1", "-W", "2000", dstIP.String()).Run()
|
||||
case "android":
|
||||
ping := "/system/bin/ping"
|
||||
if dstIP.Is6() {
|
||||
@ -447,7 +452,15 @@ func (ns *Impl) userPing(dstIP netaddr.IP, pingResPkt []byte) {
|
||||
}
|
||||
d := time.Since(t0)
|
||||
if err != nil {
|
||||
ns.logf("exec ping of %v failed in %v: %v", dstIP, d, err)
|
||||
if d < time.Second/2 {
|
||||
// If it failed quicker than the 3 second
|
||||
// timeout we gave above (500 ms is a
|
||||
// reasonable threshold), then assume the ping
|
||||
// failed for problems finding/running
|
||||
// ping. We don't want to log if the host is
|
||||
// just down.
|
||||
ns.logf("exec ping of %v failed in %v: %v", dstIP, d, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if debugNetstack {
|
||||
|
Loading…
x
Reference in New Issue
Block a user