summaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/wireguard/wireguard_timer.c')
-rw-r--r--[-rwxr-xr-x]src/plugins/wireguard/wireguard_timer.c11
1 files changed, 8 insertions, 3 deletions
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++)