From 839fee9ef4f6c806fd49b2a21cf741bf961f642c Mon Sep 17 00:00:00 2001 From: Charlotte Brandhorst-Satzkorn Date: Mon, 21 Aug 2023 14:31:34 -0700 Subject: [PATCH] wgengine/magicsock: handle wireguard only clean up and log messages This change updates log messaging when cleaning up wireguard only peers. This change also stops us unnecessarily attempting to clean up disco pings for wireguard only endpoints. Updates #7826 Signed-off-by: Charlotte Brandhorst-Satzkorn --- wgengine/magicsock/endpoint.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wgengine/magicsock/endpoint.go b/wgengine/magicsock/endpoint.go index 0496ee139..79c129a29 100644 --- a/wgengine/magicsock/endpoint.go +++ b/wgengine/magicsock/endpoint.go @@ -1335,7 +1335,11 @@ func (de *endpoint) stopAndReset() { defer de.mu.Unlock() if closing := de.c.closing.Load(); !closing { - de.c.logf("[v1] magicsock: doing cleanup for discovery key %s", de.discoShort()) + if de.isWireguardOnly { + de.c.logf("[v1] magicsock: doing cleanup for wireguard key %s", de.publicKey.ShortString()) + } else { + de.c.logf("[v1] magicsock: doing cleanup for discovery key %s", de.discoShort()) + } } de.debugUpdates.Add(EndpointChange{ @@ -1359,8 +1363,10 @@ func (de *endpoint) resetLocked() { for _, es := range de.endpointState { es.lastPing = 0 } - for txid, sp := range de.sentPing { - de.removeSentDiscoPingLocked(txid, sp) + if !de.isWireguardOnly { + for txid, sp := range de.sentPing { + de.removeSentDiscoPingLocked(txid, sp) + } } }