Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two Handhake initiation releated race-conditions fixed #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Do not flood new HandshakeInitiations, if some is already in progress
Signed-off-by: Antanas Gadeikis <[email protected]>
Antanas Gadeikis committed May 20, 2021
commit 425aa976fc4e1f918e069b9fc04c67401eaba4f2
10 changes: 8 additions & 2 deletions device/send.go
Original file line number Diff line number Diff line change
@@ -193,7 +193,10 @@ func (peer *Peer) keepKeyFreshSending() {
}
nonce := atomic.LoadUint64(&keypair.sendNonce)
if nonce > RekeyAfterMessages || (keypair.isInitiator && time.Since(keypair.created) > RekeyAfterTime) {
peer.SendHandshakeInitiation(false)
// Do not send new HandshakeInitiation, if handshake retry is already in progress
if !peer.handshakeInProgress() {
peer.SendHandshakeInitiation(false)
}
}
}

@@ -298,7 +301,10 @@ top:

keypair := peer.keypairs.Current()
if keypair == nil || atomic.LoadUint64(&keypair.sendNonce) >= RejectAfterMessages || time.Since(keypair.created) >= RejectAfterTime {
peer.SendHandshakeInitiation(false)
// Do not send new HandshakeInitiation, if handshake retry is already in progress
if !peer.handshakeInProgress() {
peer.SendHandshakeInitiation(false)
}
return
}