summaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_timer.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-10-09 11:33:55 -0400
committerDamjan Marion <dmarion@me.com>2020-10-09 17:20:28 +0000
commit6754a16ca3e01556f6d0383737aa22d89d32733b (patch)
treef66403ef75b59887dcf2cc84f7adaa4f1691c7e0 /src/plugins/wireguard/wireguard_timer.c
parent695eb9353dc4895a17d960488675b7e44c8022db (diff)
wireguard: park the timer process
Until the feature is configured. It would make sense to push more of the feature init code into the newly-added wg_feature_init() function. This patch fixes a severe hemorrhoid. Type: improvement Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I87095575363baa41407dd52492159a7b8c2899e7
Diffstat (limited to 'src/plugins/wireguard/wireguard_timer.c')
-rwxr-xr-xsrc/plugins/wireguard/wireguard_timer.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/plugins/wireguard/wireguard_timer.c b/src/plugins/wireguard/wireguard_timer.c
index b7fd6891d14..7c09617d00e 100755
--- a/src/plugins/wireguard/wireguard_timer.c
+++ b/src/plugins/wireguard/wireguard_timer.c
@@ -334,7 +334,6 @@ wg_timer_wheel_init ()
tw_timer_wheel_init_16t_2w_512sl (tw,
expired_timer_callback,
WG_TICK /* timer period in s */ , ~0);
- tw->last_run_time = vlib_time_now (wmp->vlib_main);
}
static uword
@@ -342,6 +341,28 @@ wg_timer_mngr_fn (vlib_main_t * vm, vlib_node_runtime_t * rt,
vlib_frame_t * f)
{
wg_main_t *wmp = &wg_main;
+ uword event_type = 0;
+
+ /* Park the process until the feature is configured */
+ while (1)
+ {
+ vlib_process_wait_for_event (vm);
+ event_type = vlib_process_get_events (vm, 0);
+ if (event_type == WG_START_EVENT)
+ {
+ break;
+ }
+ else
+ {
+ clib_warning ("Unknown event type %d", event_type);
+ }
+ }
+ /*
+ * Reset the timer wheel time so it won't try to
+ * expire Avogadro's number of time slots.
+ */
+ wmp->timer_wheel.last_run_time = vlib_time_now (vm);
+
while (1)
{
vlib_process_wait_for_event_or_clock (vm, WG_TICK);
@@ -377,6 +398,18 @@ VLIB_REGISTER_NODE (wg_timer_mngr_node, static) = {
};
/* *INDENT-ON* */
+void
+wg_feature_init (wg_main_t * wmp)
+{
+ if (wmp->feature_init)
+ return;
+ vlib_process_signal_event (wmp->vlib_main, wg_timer_mngr_node.index,
+ WG_START_EVENT, 0);
+ wmp->feature_init = 1;
+}
+
+
+
/*
* fd.io coding-style-patch-verification: ON
*