aboutsummaryrefslogtreecommitdiffstats
path: root/timers.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-19 01:19:53 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-19 02:40:22 +0200
commit870734ab5e1ee1dd3f8859381c9f173c30ed197f (patch)
tree472cb98ad6e519f8d625c6dc32ac5f0f3e2430f5 /timers.go
parentListen for flush in outer select (diff)
downloadwireguard-go-870734ab5e1ee1dd3f8859381c9f173c30ed197f.tar.xz
wireguard-go-870734ab5e1ee1dd3f8859381c9f173c30ed197f.zip
timers: clear send_keepalive timer on sending handshake response
We reorganize this into also doing so on sending keepalives itself, which means the state machine is much more consistent, even if this was already implied. Kernel module commit 30290ef1d2581a3e6ee8ffcdb05d580cfba976be
Diffstat (limited to 'timers.go')
-rw-r--r--timers.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/timers.go b/timers.go
index b9f6b5a..75087cb 100644
--- a/timers.go
+++ b/timers.go
@@ -143,10 +143,6 @@ func expiredPersistentKeepalive(peer *Peer) {
/* Should be called after an authenticated data packet is sent. */
func (peer *Peer) timersDataSent() {
- if peer.timersActive() {
- peer.timers.sendKeepalive.Del()
- }
-
if peer.timersActive() && !peer.timers.newHandshake.isPending {
peer.timers.newHandshake.Mod(KeepaliveTimeout + RekeyTimeout)
}
@@ -163,7 +159,14 @@ func (peer *Peer) timersDataReceived() {
}
}
-/* Should be called after any type of authenticated packet is received -- keepalive or data. */
+/* Should be called after any type of authenticated packet is sent -- keepalive, data, or handshake. */
+func (peer *Peer) timersAnyAuthenticatedPacketSent() {
+ if peer.timersActive() {
+ peer.timers.sendKeepalive.Del()
+ }
+}
+
+/* Should be called after any type of authenticated packet is received -- keepalive, data, or handshake. */
func (peer *Peer) timersAnyAuthenticatedPacketReceived() {
if peer.timersActive() {
peer.timers.newHandshake.Del()
@@ -173,7 +176,6 @@ func (peer *Peer) timersAnyAuthenticatedPacketReceived() {
/* Should be called after a handshake initiation message is sent. */
func (peer *Peer) timersHandshakeInitiated() {
if peer.timersActive() {
- peer.timers.sendKeepalive.Del()
peer.timers.retransmitHandshake.Mod(RekeyTimeout + time.Millisecond*time.Duration(rand.Int31n(RekeyTimeoutJitterMaxMs)))
}
}
@@ -195,7 +197,7 @@ func (peer *Peer) timersSessionDerived() {
}
}
-/* Should be called before a packet with authentication -- data, keepalive, either handshake -- is sent, or after one is received. */
+/* Should be called before a packet with authentication -- keepalive, data, or handshake -- is sent, or after one is received. */
func (peer *Peer) timersAnyAuthenticatedPacketTraversal() {
if peer.persistentKeepaliveInterval > 0 && peer.timersActive() {
peer.timers.persistentKeepalive.Mod(time.Duration(peer.persistentKeepaliveInterval) * time.Second)