diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-24 13:45:55 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-29 01:23:24 +0200 |
commit | 9f3bc7342dbe922dc9e387d7f421eb7f046ec50c (patch) | |
tree | 474733ae6310bb9fad45b6d89410413150ab565d /src | |
parent | qemu: build iproute2 with libmnl support (diff) | |
download | wireguard-monolithic-historical-9f3bc7342dbe922dc9e387d7f421eb7f046ec50c.tar.xz wireguard-monolithic-historical-9f3bc7342dbe922dc9e387d7f421eb7f046ec50c.zip |
timers: add jitter on ack failure reinitiation
Diffstat (limited to '')
-rw-r--r-- | src/timers.c | 6 |
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. */ |