From f6f8ea6c1b8e7d8cfeb671bfc6fbad1e2cfa6c38 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 18 May 2018 16:01:44 +0200 Subject: timers: round up instead of down in slack_time On systems with a 100hz tick, this causes handshakes to be retried in slightly less than 5 seconds, which means they aren't sent at all. This has the effect of the handshakes entirely stopping their retry cycle until the next data packet is sent. Reported-by: Andrew He --- src/timers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/timers.c b/src/timers.c index 3fc34e4..dee556d 100644 --- a/src/timers.c +++ b/src/timers.c @@ -17,10 +17,10 @@ * Timer for, if enabled, sending an empty authenticated packet every user-specified seconds */ -/* This rounds the time down to the closest power of two of the closest quarter second. */ +/* This rounds the time up to the closest power of two of the closest tenth second. */ static inline unsigned long slack_time(unsigned long time) { - return time & ~(roundup_pow_of_two(HZ / 4) - 1); + return time | roundup_pow_of_two(HZ / 10); } #define peer_get_from_timer(timer_name) \ -- cgit v1.2.3-59-g8ed1b