]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: take peer handshake when reinitializing last sent handshake
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 3 Feb 2021 16:52:31 +0000 (17:52 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 3 Feb 2021 16:52:31 +0000 (17:52 +0100)
This papers over other unrelated races, unfortunately.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
device/peer.go

index 65f73a98aae7a90f03653ee0955d65ca99b5864d..0bf19fdee828dbcd12200cdaccfe58dc2b25a97d 100644 (file)
@@ -171,6 +171,10 @@ func (peer *Peer) Start() {
        peer.stopping.Wait()
        peer.stopping.Add(2)
 
+       peer.handshake.mutex.Lock()
+       peer.handshake.lastSentHandshake = time.Now().Add(-(RekeyTimeout + time.Second))
+       peer.handshake.mutex.Unlock()
+
        // prepare queues
        peer.queue.outbound = make(chan *QueueOutboundElement, QueueOutboundSize)
        peer.queue.inbound = make(chan *QueueInboundElement, QueueInboundSize)
@@ -180,7 +184,6 @@ func (peer *Peer) Start() {
        peer.device.queue.encryption.wg.Add(1) // keep encryption queue open for our writes
 
        peer.timersInit()
-       peer.handshake.lastSentHandshake = time.Now().Add(-(RekeyTimeout + time.Second))
 
        go peer.RoutineSequentialSender()
        go peer.RoutineSequentialReceiver()