aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/wireguard/wireguard_peer.c1
-rw-r--r--[-rwxr-xr-x]src/plugins/wireguard/wireguard_peer.h1
-rw-r--r--[-rwxr-xr-x]src/plugins/wireguard/wireguard_timer.c11
3 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/wireguard/wireguard_peer.c b/src/plugins/wireguard/wireguard_peer.c
index c4f06be999d..f47019b110a 100644
--- a/src/plugins/wireguard/wireguard_peer.c
+++ b/src/plugins/wireguard/wireguard_peer.c
@@ -81,6 +81,7 @@ wg_peer_clear (vlib_main_t * vm, wg_peer_t * peer)
for (int i = 0; i < WG_N_TIMERS; i++)
{
peer->timers[i] = ~0;
+ peer->timers_dispatched[i] = 0;
}
peer->last_sent_handshake = vlib_time_now (vm) - (REKEY_TIMEOUT + 1);
diff --git a/src/plugins/wireguard/wireguard_peer.h b/src/plugins/wireguard/wireguard_peer.h
index 50c0a012fe2..b60c669ac0f 100755..100644
--- a/src/plugins/wireguard/wireguard_peer.h
+++ b/src/plugins/wireguard/wireguard_peer.h
@@ -71,6 +71,7 @@ typedef struct wg_peer
/* Timers */
tw_timer_wheel_16t_2w_512sl_t *timer_wheel;
u32 timers[WG_N_TIMERS];
+ u8 timers_dispatched[WG_N_TIMERS];
u32 timer_handshake_attempts;
u16 persistent_keepalive_interval;
diff --git a/src/plugins/wireguard/wireguard_timer.c b/src/plugins/wireguard/wireguard_timer.c
index 7c09617d00e..b245b853fb5 100755..100644
--- a/src/plugins/wireguard/wireguard_timer.c
+++ b/src/plugins/wireguard/wireguard_timer.c
@@ -62,7 +62,6 @@ start_timer_thread_fn (void *arg)
{
wg_timers_args *a = arg;
wg_peer_t *peer = wg_peer_get (a->peer_idx);
-
start_timer (peer, a->timer_id, a->interval_ticks);
return 0;
}
@@ -75,8 +74,11 @@ start_timer_from_mt (u32 peer_idx, u32 timer_id, u32 interval_ticks)
.timer_id = timer_id,
.interval_ticks = interval_ticks,
};
-
- vl_api_rpc_call_main_thread (start_timer_thread_fn, (u8 *) & a, sizeof (a));
+ wg_peer_t *peer = wg_peer_get (peer_idx);
+ if (PREDICT_FALSE (!peer->timers_dispatched[timer_id]))
+ if (!clib_atomic_cmp_and_swap (&peer->timers_dispatched[timer_id], 0, 1))
+ vl_api_rpc_call_main_thread (start_timer_thread_fn, (u8 *) &a,
+ sizeof (a));
}
static inline u32
@@ -295,6 +297,9 @@ expired_timer_callback (u32 * expired_timers)
peer = wg_peer_get (pool_index);
peer->timers[timer_id] = ~0;
+
+ /* Under barrier, no sync needed */
+ peer->timers_dispatched[timer_id] = 0;
}
for (i = 0; i < vec_len (expired_timers); i++)