summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-10-19 02:16:40 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-10-19 17:21:49 +0900
commit60f41e89e367b87223dc6e77cc75ef977b521edf (patch)
tree16155407343e4d021ce59497eb9c36b1d186ea31 /src
parente465dee018b3471271e227f1e17290162d7164a1 (diff)
timers: avoid thundering herd for simultaneous initiation
Since it's extremely unlikely for jiffies to be exactly identical everywhere, applying quarter second power of two slack not only improves power efficiency but also ensures that retries have a bit of jitter. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/timers.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/timers.c b/src/timers.c
index d16d7d1..c37b294 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -123,7 +123,7 @@ void timers_handshake_initiated(struct wireguard_peer *peer)
if (likely(peer->timer_send_keepalive.data))
del_timer(&peer->timer_send_keepalive);
if (likely(peer->timer_retransmit_handshake.data))
- mod_timer(&peer->timer_retransmit_handshake, jiffies + REKEY_TIMEOUT);
+ mod_timer(&peer->timer_retransmit_handshake, slack_time(jiffies + REKEY_TIMEOUT + HZ / 4));
}
/* Should be called after a handshake response message is received and processed. */