Skip to content

Commit

Permalink
device: only propagate roaming value before peer is referenced elsewhere
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
zx2c4 committed Nov 16, 2021
1 parent fc4f975 commit de7c702
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion device/uapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit de7c702

Please sign in to comment.