wgengine: add temp workaround for netstack WhoIs registration race

Updates #1616

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/1618/head
Brad Fitzpatrick 4 years ago
parent 33bc69cf1f
commit 91bc723817

@ -1438,11 +1438,30 @@ func (e *userspaceEngine) UnregisterIPPortIdentity(ipport netaddr.IPPort) {
delete(e.tsIPByIPPort, ipport)
}
var whoIsSleeps = [...]time.Duration{
0,
10 * time.Millisecond,
20 * time.Millisecond,
50 * time.Millisecond,
100 * time.Millisecond,
}
func (e *userspaceEngine) WhoIsIPPort(ipport netaddr.IPPort) (tsIP netaddr.IP, ok bool) {
// We currently have a registration race,
// https://github.com/tailscale/tailscale/issues/1616,
// so loop a few times for now waiting for the registration
// to appear.
// TODO(bradfitz,namansood): remove this once #1616 is fixed.
for _, d := range whoIsSleeps {
time.Sleep(d)
e.mu.Lock()
defer e.mu.Unlock()
tsIP, ok = e.tsIPByIPPort[ipport]
return tsIP, ok
e.mu.Unlock()
if ok {
return tsIP, true
}
}
return tsIP, false
}
// peerForIP returns the Node in the wireguard config

Loading…
Cancel
Save