summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-05-31 04:45:59 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-05-31 05:36:57 +0200
commitc37516456eeca6404f2d61d16561101f84f8e790 (patch)
treea6c108d26510c88b47a6ae1d8953339cad1763a3
parentc0ad0d970830ac680bed6f143743096be82cef51 (diff)
timers: rework handshake reply control flow
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/timers.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/timers.c b/src/timers.c
index ff422b1..a8cd537 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -28,7 +28,7 @@ static void expired_retransmit_handshake(unsigned long ptr)
{
peer_get_from_ptr(ptr);
if (peer->timer_handshake_attempts > MAX_TIMER_HANDSHAKES) {
- pr_debug("%s: Handshake for peer %Lu (%pISpfsc) did not complete after %d attempts, giving up\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, MAX_TIMER_HANDSHAKES);
+ pr_debug("%s: Handshake for peer %Lu (%pISpfsc) did not complete after %d attempts, giving up\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, MAX_TIMER_HANDSHAKES + 2);
del_timer(&peer->timer_send_keepalive);
/* We remove all existing packets and don't try again,
@@ -38,16 +38,15 @@ static void expired_retransmit_handshake(unsigned long ptr)
* of a partial exchange. */
if (likely(peer->timers_enabled))
mod_timer(&peer->timer_kill_ephemerals, jiffies + (REJECT_AFTER_TIME * 3));
- goto out;
- }
- pr_debug("%s: Handshake for peer %Lu (%pISpfsc) did not complete after %d seconds, retrying\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, REKEY_TIMEOUT / HZ);
+ } else {
+ ++peer->timer_handshake_attempts;
+ pr_debug("%s: Handshake for peer %Lu (%pISpfsc) did not complete after %d seconds, retrying (try %d)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, REKEY_TIMEOUT / HZ, peer->timer_handshake_attempts + 1);
- /* We clear the endpoint address src address, in case this is the cause of trouble. */
- socket_clear_peer_endpoint_src(peer);
+ /* 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);
- ++peer->timer_handshake_attempts;
-out:
+ packet_queue_handshake_initiation(peer);
+ }
peer_put(peer);
}