diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-02 14:26:28 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-03 14:01:01 +0100 |
commit | c8b111bad16160aec5cf944bcf6fb1da47d601db (patch) | |
tree | 815b8ac6c458b7f2ee856378c6cf3f3a62fe0d68 /src/send.c | |
parent | tools: abstract pkg-config to PKG_CONFIG (diff) | |
download | wireguard-monolithic-historical-c8b111bad16160aec5cf944bcf6fb1da47d601db.tar.xz wireguard-monolithic-historical-c8b111bad16160aec5cf944bcf6fb1da47d601db.zip |
timers: take reference like a lookup table
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -33,8 +33,11 @@ void packet_send_handshake_initiation(struct wireguard_peer *peer) void packet_send_handshake_initiation_ratelimited(struct wireguard_peer *peer) { - if (time_is_before_jiffies64(peer->last_sent_handshake + REKEY_TIMEOUT)) - packet_queue_send_handshake_initiation(peer); + if (time_is_before_jiffies64(peer->last_sent_handshake + REKEY_TIMEOUT)) { + peer = peer_rcu_get(peer); + if (likely(peer)) + packet_queue_send_handshake_initiation(peer); + } } void packet_send_handshake_response(struct wireguard_peer *peer) @@ -62,13 +65,9 @@ void packet_send_queued_handshakes(struct work_struct *work) peer_put(peer); } +/* Consumes peer reference. */ void packet_queue_send_handshake_initiation(struct wireguard_peer *peer) { - rcu_read_lock(); - peer = peer_get(peer); - rcu_read_unlock(); - if (!peer) - return; /* Queues up calling packet_send_queued_handshakes(peer), where we do a peer_put(peer) after: */ if (!queue_work(peer->device->workqueue, &peer->transmit_handshake_work)) peer_put(peer); /* If the work was already queued, we want to drop the extra reference */ |