summaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_timer.c
diff options
context:
space:
mode:
authorMohammed Hawari <mohammed@hawari.fr>2021-01-12 17:00:21 +0100
committerBeno�t Ganne <bganne@cisco.com>2021-02-11 08:38:48 +0000
commitd5d253d618d7c381cfc9d1b557b5242e2dd2c2e7 (patch)
tree5d8761f0fdb83dc306717dbce4fb5441d59eb6f6 /src/plugins/wireguard/wireguard_timer.c
parente3845d79bfa819355ac5085d73f3b8f2ffae2042 (diff)
wireguard: testing alternative timer dispatch
Change-Id: I645bb0a31b333a6160c74987dddb3fb50ff154d8 Type: improvement Signed-off-by: Mohammed Hawari <mohammed@hawari.fr>
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++)