mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-18 20:51:45 +00:00
wgengine: add temp workaround for netstack WhoIs registration race
Updates #1616 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
33bc69cf1f
commit
91bc723817
@ -1438,11 +1438,30 @@ func (e *userspaceEngine) UnregisterIPPortIdentity(ipport netaddr.IPPort) {
|
|||||||
delete(e.tsIPByIPPort, 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) {
|
func (e *userspaceEngine) WhoIsIPPort(ipport netaddr.IPPort) (tsIP netaddr.IP, ok bool) {
|
||||||
e.mu.Lock()
|
// We currently have a registration race,
|
||||||
defer e.mu.Unlock()
|
// https://github.com/tailscale/tailscale/issues/1616,
|
||||||
tsIP, ok = e.tsIPByIPPort[ipport]
|
// so loop a few times for now waiting for the registration
|
||||||
return tsIP, ok
|
// to appear.
|
||||||
|
// TODO(bradfitz,namansood): remove this once #1616 is fixed.
|
||||||
|
for _, d := range whoIsSleeps {
|
||||||
|
time.Sleep(d)
|
||||||
|
e.mu.Lock()
|
||||||
|
tsIP, ok = e.tsIPByIPPort[ipport]
|
||||||
|
e.mu.Unlock()
|
||||||
|
if ok {
|
||||||
|
return tsIP, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tsIP, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// peerForIP returns the Node in the wireguard config
|
// peerForIP returns the Node in the wireguard config
|
||||||
|
Loading…
x
Reference in New Issue
Block a user