aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/timers.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-22 22:33:53 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-07-23 00:58:05 +0200
commit6ad3f1d59e91c8871f08b379424e1fb1e56c2537 (patch)
tree5c22362738a48e286156d135fab8708c0a5c123e /src/timers.c
parenttools: use stream instead of seqpacket (diff)
downloadwireguard-monolithic-historical-6ad3f1d59e91c8871f08b379424e1fb1e56c2537.tar.xz
wireguard-monolithic-historical-6ad3f1d59e91c8871f08b379424e1fb1e56c2537.zip
timers: upstream removed the slack concept
No longer do we specify slack ourselves. Instead we need to add it directly in the main scheduling.
Diffstat (limited to 'src/timers.c')
-rw-r--r--src/timers.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/timers.c b/src/timers.c
index 4f840c6..636b851 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -18,6 +18,12 @@ enum {
* 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. */
+static inline unsigned long slack_time(unsigned long time)
+{
+ return time & ~(BIT_MASK(ilog2(HZ / 4) + 1) - 1);
+}
+
static void expired_retransmit_handshake(unsigned long ptr)
{
struct wireguard_peer *peer = (struct wireguard_peer *)ptr;
@@ -142,7 +148,7 @@ void timers_ephemeral_key_created(struct wireguard_peer *peer)
void timers_any_authenticated_packet_traversal(struct wireguard_peer *peer)
{
if (peer->persistent_keepalive_interval && likely(peer->timer_persistent_keepalive.data))
- mod_timer(&peer->timer_persistent_keepalive, jiffies + peer->persistent_keepalive_interval);
+ mod_timer(&peer->timer_persistent_keepalive, slack_time(jiffies + peer->persistent_keepalive_interval));
}
void timers_init_peer(struct wireguard_peer *peer)
@@ -154,12 +160,10 @@ void timers_init_peer(struct wireguard_peer *peer)
init_timer(&peer->timer_send_keepalive);
peer->timer_send_keepalive.function = expired_send_keepalive;
peer->timer_send_keepalive.data = (unsigned long)peer;
- set_timer_slack(&peer->timer_send_keepalive, HZ / 4);
init_timer(&peer->timer_new_handshake);
peer->timer_new_handshake.function = expired_new_handshake;
peer->timer_new_handshake.data = (unsigned long)peer;
- set_timer_slack(&peer->timer_new_handshake, HZ / 4);
init_timer(&peer->timer_kill_ephemerals);
peer->timer_kill_ephemerals.function = expired_kill_ephemerals;
@@ -168,7 +172,6 @@ void timers_init_peer(struct wireguard_peer *peer)
init_timer(&peer->timer_persistent_keepalive);
peer->timer_persistent_keepalive.function = expired_send_persistent_keepalive;
peer->timer_persistent_keepalive.data = (unsigned long)peer;
- set_timer_slack(&peer->timer_persistent_keepalive, max_t(int, HZ / 2, peer->persistent_keepalive_interval / 256));
INIT_WORK(&peer->clear_peer_work, queued_expired_kill_ephemerals);
}