From cd7bc02ab1924a5504c6667ffebdb0635272badd Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Tue, 25 Aug 2020 10:22:36 -0400 Subject: [PATCH] magicsock: call RequestStatus when DERP connects Without this, a freshly started ipn client will be stuck in the "Starting" state until something triggers a call to RequestStatus. Usually a UI does this, but until then we can sit in this state until poked by an external event, as is evidenced by our e2e tests locking up when DERP is attached. (This only recently became a problem when we enabled lazy handshaking everywhere, otherwise the wireugard tunnel creation would also trigger a RequestStatus.) Signed-off-by: David Crawshaw --- wgengine/magicsock/magicsock.go | 1 + wgengine/userspace.go | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index d20389a10..00036ae0e 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -1206,6 +1206,7 @@ func (c *Conn) derpWriteChanOfAddr(addr netaddr.IPPort, peer key.Public) chan<- go c.runDerpReader(ctx, addr, dc, wg, startGate) go c.runDerpWriter(ctx, dc, ch, wg, startGate) + go c.epFunc(nil) // call RequestStatus with DERPs change return ad.writeCh } diff --git a/wgengine/userspace.go b/wgengine/userspace.go index b5c0790af..a261da24f 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -229,10 +229,11 @@ func newUserspaceEngineAdvanced(conf EngineConfig) (_ Engine, reterr error) { e.linkMon = mon endpointsFn := func(endpoints []string) { - e.mu.Lock() - e.endpoints = append(e.endpoints[:0], endpoints...) - e.mu.Unlock() - + if len(endpoints) != 0 { + e.mu.Lock() + e.endpoints = append(e.endpoints[:0], endpoints...) + e.mu.Unlock() + } e.RequestStatus() } magicsockOpts := magicsock.Options{