From 521b44e653e2923a5a5e262072a81d31c4d5cac8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 18 Oct 2021 10:14:42 -0700 Subject: [PATCH] wgengine/magicsock: move discoKey fields to the mutex-protected section. Fixes #3106 Signed-off-by: David Anderson --- wgengine/magicsock/magicsock.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 312226b55..0cdf13a2b 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -3104,15 +3104,16 @@ type endpoint struct { // These fields are initialized once and never modified. c *Conn - publicKey tailcfg.NodeKey // peer public key (for WireGuard + DERP) - discoKey tailcfg.DiscoKey // for discovery messages. IsZero() if peer can't disco. - discoShort string // ShortString of discoKey. Empty if peer can't disco. - fakeWGAddr netaddr.IPPort // the UDP address we tell wireguard-go we're using - wgEndpoint string // string from ParseEndpoint, holds a JSON-serialized wgcfg.Endpoints + publicKey tailcfg.NodeKey // peer public key (for WireGuard + DERP) + fakeWGAddr netaddr.IPPort // the UDP address we tell wireguard-go we're using + wgEndpoint string // string from ParseEndpoint, holds a JSON-serialized wgcfg.Endpoints // mu protects all following fields. mu sync.Mutex // Lock ordering: Conn.mu, then endpoint.mu + discoKey tailcfg.DiscoKey // for discovery messages. IsZero() if peer can't disco. + discoShort string // ShortString of discoKey. Empty if peer can't disco. + heartBeatTimer *time.Timer // nil when idle lastSend mono.Time // last time there was outgoing packets sent to this peer (from wireguard-go) lastFullPing mono.Time // last time we pinged all endpoints