aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/timers.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-10 20:41:00 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-07-10 21:44:38 +0200
commite9ccb85445153e5fa09d607f9afbd5a78b534844 (patch)
tree0e0f17882479a532ee5ef2a8788b8ca8ae3c7ebb /src/timers.c
parenttimers: move timer calls out of hot loop (diff)
downloadwireguard-linux-compat-e9ccb85445153e5fa09d607f9afbd5a78b534844.tar.xz
wireguard-linux-compat-e9ccb85445153e5fa09d607f9afbd5a78b534844.zip
timers: apply slack to hotpath timers
For timers in the hotpath, we don't want them to be rescheduled so aggressively, and since they don't need to be that precise, we can set a decent amount of slack. With the persistent keepalive timer, we have something of a special case. Since the timeout isn't fixed like the others, we don't want to make it more often than the kernel ordinarily would. So, instead, we make it a minimum. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r--src/timers.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/timers.c b/src/timers.c
index 190cb6e..4f840c6 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -154,10 +154,12 @@ 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;
@@ -166,6 +168,7 @@ 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);
}