wgengine/magicsock: move discoKey fields to the mutex-protected section.

Fixes #3106

Signed-off-by: David Anderson <danderson@tailscale.com>
(cherry picked from commit 521b44e653)
This commit is contained in:
David Anderson 2021-10-18 10:14:42 -07:00 committed by Brad Fitzpatrick
parent cb0d784a79
commit ee02c95259

View File

@ -3104,15 +3104,16 @@ type endpoint struct {
// These fields are initialized once and never modified. // These fields are initialized once and never modified.
c *Conn c *Conn
publicKey tailcfg.NodeKey // peer public key (for WireGuard + DERP) publicKey tailcfg.NodeKey // peer public key (for WireGuard + DERP)
discoKey tailcfg.DiscoKey // for discovery messages. IsZero() if peer can't disco. fakeWGAddr netaddr.IPPort // the UDP address we tell wireguard-go we're using
discoShort string // ShortString of discoKey. Empty if peer can't disco. wgEndpoint string // string from ParseEndpoint, holds a JSON-serialized wgcfg.Endpoints
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 protects all following fields.
mu sync.Mutex // Lock ordering: Conn.mu, then endpoint.mu 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 heartBeatTimer *time.Timer // nil when idle
lastSend mono.Time // last time there was outgoing packets sent to this peer (from wireguard-go) 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 lastFullPing mono.Time // last time we pinged all endpoints