summaryrefslogtreecommitdiffhomepage
path: root/src/timers.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-24 13:45:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-29 01:23:24 +0200
commit417713f678efdb682bedfd1aa678c9fca289de73 (patch)
tree81e424a81d317097a7f9fce90b9fbafab81b9dd6 /src/timers.c
parentf3ab052835f6ffa20bad87ea6f0efdd26b53b2cd (diff)
timers: add jitter on ack failure reinitiation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r--src/timers.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/timers.c b/src/timers.c
index 7614c85..d54d32a 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -17,7 +17,8 @@
* not sent one for `KEEPALIVE_TIMEOUT` ms.
*
* - Timer for initiating new handshake if we have sent a packet but after have
- * not received one (even empty) for `(KEEPALIVE_TIMEOUT + REKEY_TIMEOUT)` ms.
+ * not received one (even empty) for `(KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) +
+ * jitter` ms.
*
* - Timer for zeroing out all ephemeral keys after `(REJECT_AFTER_TIME * 3)` ms
* if no new keys have been received.
@@ -145,7 +146,8 @@ void wg_timers_data_sent(struct wg_peer *peer)
{
if (!timer_pending(&peer->timer_new_handshake))
mod_peer_timer(peer, &peer->timer_new_handshake,
- jiffies + (KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) * HZ);
+ jiffies + (KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) * HZ +
+ prandom_u32_max(REKEY_TIMEOUT_JITTER_MAX_JIFFIES));
}
/* Should be called after an authenticated data packet is received. */