diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-31 22:30:37 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-11-01 00:55:19 +0100 |
commit | 47b9e2396a11181ecd8bae10a4a7589efd1c80bf (patch) | |
tree | c68078a9b1bb798eeecc970ab4610769497208f4 /src/timers.c | |
parent | bf81b89b923c12d180f82e987905c8d664cd3761 (diff) |
timers: switch to kees' new timer_list functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r-- | src/timers.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/timers.c b/src/timers.c index af7a912..52fff28 100644 --- a/src/timers.c +++ b/src/timers.c @@ -20,8 +20,8 @@ static inline unsigned long slack_time(unsigned long time) return time & ~(roundup_pow_of_two(HZ / 4) - 1); } -#define peer_get_from_ptr(ptr) \ - struct wireguard_peer *peer = peer_rcu_get((struct wireguard_peer *)ptr); \ +#define peer_get_from_timer(timer_name) \ + struct wireguard_peer *peer = peer_rcu_get(from_timer(peer, timer, timer_name)); \ if (unlikely(!peer)) \ return; @@ -30,9 +30,9 @@ static inline bool timers_active(struct wireguard_peer *peer) return netif_running(peer->device->dev) && !list_empty(&peer->peer_list); } -static void expired_retransmit_handshake(unsigned long ptr) +static void expired_retransmit_handshake(struct timer_list *timer) { - peer_get_from_ptr(ptr); + peer_get_from_timer(timer_retransmit_handshake); if (peer->timer_handshake_attempts > MAX_TIMER_HANDSHAKES) { pr_debug("%s: Handshake for peer %llu (%pISpfsc) did not complete after %d attempts, giving up\n", peer->device->dev->name, peer->internal_id, &peer->endpoint.addr, MAX_TIMER_HANDSHAKES + 2); @@ -61,9 +61,9 @@ static void expired_retransmit_handshake(unsigned long ptr) peer_put(peer); } -static void expired_send_keepalive(unsigned long ptr) +static void expired_send_keepalive(struct timer_list *timer) { - peer_get_from_ptr(ptr); + peer_get_from_timer(timer_send_keepalive); packet_send_keepalive(peer); if (peer->timer_need_another_keepalive) { @@ -74,9 +74,9 @@ static void expired_send_keepalive(unsigned long ptr) peer_put(peer); } -static void expired_new_handshake(unsigned long ptr) +static void expired_new_handshake(struct timer_list *timer) { - peer_get_from_ptr(ptr); + peer_get_from_timer(timer_new_handshake); pr_debug("%s: Retrying handshake with peer %llu (%pISpfsc) because we stopped hearing back after %d seconds\n", peer->device->dev->name, peer->internal_id, &peer->endpoint.addr, (KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) / HZ); /* We clear the endpoint address src address, in case this is the cause of trouble. */ @@ -85,9 +85,9 @@ static void expired_new_handshake(unsigned long ptr) peer_put(peer); } -static void expired_zero_key_material(unsigned long ptr) +static void expired_zero_key_material(struct timer_list *timer) { - peer_get_from_ptr(ptr); + peer_get_from_timer(timer_zero_key_material); if (!queue_work(peer->device->handshake_send_wq, &peer->clear_peer_work)) /* Takes our reference. */ peer_put(peer); /* If the work was already on the queue, we want to drop the extra reference */ @@ -102,9 +102,9 @@ static void queued_expired_zero_key_material(struct work_struct *work) peer_put(peer); } -static void expired_send_persistent_keepalive(unsigned long ptr) +static void expired_send_persistent_keepalive(struct timer_list *timer) { - peer_get_from_ptr(ptr); + peer_get_from_timer(timer_persistent_keepalive); if (likely(peer->persistent_keepalive_interval)) { if (likely(timers_active(peer))) @@ -177,11 +177,11 @@ void timers_any_authenticated_packet_traversal(struct wireguard_peer *peer) void timers_init(struct wireguard_peer *peer) { - setup_timer(&peer->timer_retransmit_handshake, expired_retransmit_handshake, (unsigned long)peer); - setup_timer(&peer->timer_send_keepalive, expired_send_keepalive, (unsigned long)peer); - setup_timer(&peer->timer_new_handshake, expired_new_handshake, (unsigned long)peer); - setup_timer(&peer->timer_zero_key_material, expired_zero_key_material, (unsigned long)peer); - setup_timer(&peer->timer_persistent_keepalive, expired_send_persistent_keepalive, (unsigned long)peer); + timer_setup(&peer->timer_retransmit_handshake, expired_retransmit_handshake, 0); + timer_setup(&peer->timer_send_keepalive, expired_send_keepalive, 0); + timer_setup(&peer->timer_new_handshake, expired_new_handshake, 0); + timer_setup(&peer->timer_zero_key_material, expired_zero_key_material, 0); + timer_setup(&peer->timer_persistent_keepalive, expired_send_persistent_keepalive, 0); INIT_WORK(&peer->clear_peer_work, queued_expired_zero_key_material); } |