From e10da62bd6341f214264006b4196281299c66b62 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Sun, 25 Oct 2020 14:00:29 -0700 Subject: session: fix feature disable Type: fix Signed-off-by: Florin Coras Change-Id: I69e912ddf64d8ec89f8d93e02a201781b99de0bd --- src/vnet/session/session.c | 18 ++++++++++++++++-- src/vnet/session/session.h | 4 ++++ src/vnet/session/session_node.c | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index 6413da51f3b..18850cc1ba2 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -1665,6 +1665,10 @@ session_manager_main_enable (vlib_main_t * vm) session_worker_t *wrk; int i; + /* We only initialize once and do not de-initialized on disable */ + if (smm->is_initialized) + goto done; + num_threads = 1 /* main thread */ + vtm->n_threads; if (num_threads < 1) @@ -1721,6 +1725,9 @@ session_manager_main_enable (vlib_main_t * vm) session_lookup_init (); app_namespaces_init (); transport_init (); + smm->is_initialized = 1; + +done: smm->is_enabled = 1; @@ -1731,6 +1738,12 @@ session_manager_main_enable (vlib_main_t * vm) return 0; } +static void +session_manager_main_disable (vlib_main_t * vm) +{ + transport_enable_disable (vm, 0 /* is_en */ ); +} + void session_node_enable_disable (u8 is_en) { @@ -1742,10 +1755,10 @@ session_node_enable_disable (u8 is_en) foreach_vlib_main (({ if (have_workers && ii == 0) { - vlib_node_set_state (this_vlib_main, session_queue_process_node.index, - state); if (is_en) { + vlib_node_set_state (this_vlib_main, + session_queue_process_node.index, state); vlib_node_t *n = vlib_get_node (this_vlib_main, session_queue_process_node.index); vlib_start_process (this_vlib_main, n->runtime_index); @@ -1780,6 +1793,7 @@ vnet_session_enable_disable (vlib_main_t * vm, u8 is_en) else { session_main.is_enabled = 0; + session_manager_main_disable (vm); session_node_enable_disable (is_en); } diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h index 5e0a832d796..2de22bd2650 100644 --- a/src/vnet/session/session.h +++ b/src/vnet/session/session.h @@ -164,6 +164,10 @@ typedef struct session_main_ /** Session manager is enabled */ u8 is_enabled; + + /** Session manager initialized (not necessarily enabled) */ + u8 is_initialized; + /** Enable session manager at startup */ u8 session_enable_asap; diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 346b9f43343..482f8b019ff 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -1564,6 +1564,8 @@ session_queue_process (vlib_main_t * vm, vlib_node_runtime_t * rt, session_queue_run_on_main (vm); break; case SESSION_Q_PROCESS_STOP: + vlib_node_set_state (vm, session_queue_process_node.index, + VLIB_NODE_STATE_DISABLED); timeout = 100000.0; break; case ~0: -- cgit 1.2.3-korg