From de7c702ace45b8eeba7f4de8ecd9c85c80806264 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 16 Nov 2021 21:13:55 +0100 Subject: [PATCH] device: only propagate roaming value before peer is referenced elsewhere A peer.endpoint never becomes nil after being not-nil, so creation is the only time we actually need to set this. This prevents a race from when the variable is actually used elsewhere, and allows us to avoid an expensive atomic. Signed-off-by: Jason A. Donenfeld --- device/uapi.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/device/uapi.go b/device/uapi.go index 87c5dd9..2306183 100644 --- a/device/uapi.go +++ b/device/uapi.go @@ -261,7 +261,9 @@ func (peer *ipcSetPeer) handlePostConfig() { if peer.Peer == nil || peer.dummy { return } - peer.disableRoaming = peer.device.net.brokenRoaming && peer.endpoint != nil + if peer.created { + peer.disableRoaming = peer.device.net.brokenRoaming && peer.endpoint != nil + } if peer.device.isUp() { peer.Start() if peer.pkaOn {