diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-05-31 05:32:36 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-05-31 14:23:13 +0200 |
commit | fab890e613df4e8814b78b6548c9d9f60d5909f4 (patch) | |
tree | 0e1288bcc6d28f55f11147f7658cef8c8c2156d8 /src | |
parent | 4061a818b2af5a4522eedf46b4e756e1a785f79c (diff) |
timers: reset retry-attempt counter when not retrying
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/packets.h | 2 | ||||
-rw-r--r-- | src/receive.c | 2 | ||||
-rw-r--r-- | src/send.c | 9 | ||||
-rw-r--r-- | src/timers.c | 4 |
4 files changed, 10 insertions, 7 deletions
diff --git a/src/packets.h b/src/packets.h index be9cfd7..0e909d3 100644 --- a/src/packets.h +++ b/src/packets.h @@ -28,7 +28,7 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer, /* send.c */ void packet_send_queue(struct wireguard_peer *peer); void packet_send_keepalive(struct wireguard_peer *peer); -void packet_queue_handshake_initiation(struct wireguard_peer *peer); +void packet_queue_handshake_initiation(struct wireguard_peer *peer, bool is_retry); void packet_send_queued_handshakes(struct work_struct *work); void packet_send_handshake_response(struct wireguard_peer *peer); void packet_send_handshake_cookie(struct wireguard_device *wg, struct sk_buff *initiating_skb, __le32 sender_index); diff --git a/src/receive.c b/src/receive.c index 6051c2c..b582d00 100644 --- a/src/receive.c +++ b/src/receive.c @@ -197,7 +197,7 @@ static void keep_key_fresh(struct wireguard_peer *peer) if (send) { peer->sent_lastminute_handshake = true; - packet_queue_handshake_initiation(peer); + packet_queue_handshake_initiation(peer, false); } } @@ -44,8 +44,11 @@ void packet_send_queued_handshakes(struct work_struct *work) peer_put(peer); } -void packet_queue_handshake_initiation(struct wireguard_peer *peer) +void packet_queue_handshake_initiation(struct wireguard_peer *peer, bool is_retry) { + if (!is_retry) + peer->timer_handshake_attempts = 0; + /* First checking the timestamp here is just an optimization; it will * be caught while properly locked inside the actual work queue. */ if (!time_is_before_jiffies64(peer->last_sent_handshake + REKEY_TIMEOUT)) @@ -100,7 +103,7 @@ static inline void keep_key_fresh(struct wireguard_peer *peer) rcu_read_unlock_bh(); if (send) - packet_queue_handshake_initiation(peer); + packet_queue_handshake_initiation(peer, false); } void packet_send_keepalive(struct wireguard_peer *peer) @@ -183,7 +186,7 @@ void packet_send_queue(struct wireguard_peer *peer) skb_queue_splice(&queue, &peer->tx_packet_queue); spin_unlock_bh(&peer->tx_packet_queue.lock); - packet_queue_handshake_initiation(peer); + packet_queue_handshake_initiation(peer, false); break; default: /* If we failed for any other reason, we want to just free the packets and diff --git a/src/timers.c b/src/timers.c index 209fe5a..cd37580 100644 --- a/src/timers.c +++ b/src/timers.c @@ -45,7 +45,7 @@ static void expired_retransmit_handshake(unsigned long ptr) /* We clear the endpoint address src address, in case this is the cause of trouble. */ socket_clear_peer_endpoint_src(peer); - packet_queue_handshake_initiation(peer); + packet_queue_handshake_initiation(peer, true); } peer_put(peer); } @@ -68,7 +68,7 @@ static void expired_new_handshake(unsigned long ptr) pr_debug("%s: Retrying handshake with peer %Lu (%pISpfsc) because we stopped hearing back after %d seconds\n", netdev_pub(peer->device)->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. */ socket_clear_peer_endpoint_src(peer); - packet_queue_handshake_initiation(peer); + packet_queue_handshake_initiation(peer, false); peer_put(peer); } |