]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: only propagate roaming value before peer is referenced elsewhere
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 16 Nov 2021 20:13:55 +0000 (21:13 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 16 Nov 2021 20:16:04 +0000 (21:16 +0100)
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 <Jason@zx2c4.com>
device/uapi.go

index 87c5dd9cd7e53a0e5edd26201866829222c046da..2306183a648a3c7c5f9abbcb7328d51309228ed8 100644 (file)
@@ -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 {