From 53badfc6839da351c1d1dd7f1422418b0696c580 Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Tue, 24 Jan 2023 16:10:29 +0700 Subject: wireguard: sending the first handshake After creating a peer, we send a handshake request. But it's not quite right to call wg_send_keepalive() directly. According to documentation, handshake initiation is sent after (REKEY_TIMEOUT + jitter) ms. Since it's the first one - we don't need to take REKEY_TIMEOUT into account, but we still have jitter. It also makes no sense to immediately send keepalives, because the connection is not created yet. Type: fix Signed-off-by: Artem Glazychev Change-Id: I61707e4be79be65abc3396b5f1dbd48ecbf7ba60 --- src/plugins/wireguard/wireguard_timer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/plugins/wireguard/wireguard_timer.c') diff --git a/src/plugins/wireguard/wireguard_timer.c b/src/plugins/wireguard/wireguard_timer.c index b95801122fc..4319d534ffc 100644 --- a/src/plugins/wireguard/wireguard_timer.c +++ b/src/plugins/wireguard/wireguard_timer.c @@ -238,6 +238,16 @@ wg_timers_handshake_initiated (wg_peer_t * peer) peer->rehandshake_interval_tick); } +void +wg_timers_send_first_handshake (wg_peer_t *peer) +{ + // zero value is not allowed + peer->new_handshake_interval_tick = + get_random_u32_max (REKEY_TIMEOUT_JITTER) + 1; + start_timer_from_mt (peer - wg_peer_pool, WG_TIMER_NEW_HANDSHAKE, + peer->new_handshake_interval_tick); +} + void wg_timers_session_derived (wg_peer_t * peer) { -- cgit 1.2.3-korg