aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/timers.c
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
commitd015bd418de70e55fa51d8434f25c35e072724b3 (patch)
treebdfd2b201fd2fb3c1f4e4f40ff1d58ca1c5a37d3 /src/timers.c
parentdebug: print interface name in dmesg (diff)
downloadwireguard-monolithic-historical-d015bd418de70e55fa51d8434f25c35e072724b3.tar.xz
wireguard-monolithic-historical-d015bd418de70e55fa51d8434f25c35e072724b3.zip
timers: rework handshake reply control flow
Diffstat (limited to 'src/timers.c')
-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);
}