diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-10 20:41:00 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-10 21:44:38 +0200 |
commit | a1fd983efd1776f0053fac5e0e487226aca9adb6 (patch) | |
tree | 23b4c603394064daa493aa112b29b253419061b8 /src/timers.c | |
parent | timers: move timer calls out of hot loop (diff) | |
download | wireguard-monolithic-historical-a1fd983efd1776f0053fac5e0e487226aca9adb6.tar.xz wireguard-monolithic-historical-a1fd983efd1776f0053fac5e0e487226aca9adb6.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.
Diffstat (limited to 'src/timers.c')
-rw-r--r-- | src/timers.c | 3 |
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); } |