summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2022-12-22 15:01:32 +0100
committerFlorin Coras <florin.coras@gmail.com>2022-12-23 17:18:53 +0000
commitc5b0fcd159d471f0422b303a2efa5ba6e8ddfcd6 (patch)
treedf43592fa4aec20ddf0eaaf7db229e78042e5968 /src/plugins
parentb89db0cf75a5fe2768b7ef53fac2efb8c4b84ca0 (diff)
hsa: fix echo client workers initialization
We were creating an additional worker not backed by any VPP threads, leading off-by-1 access in the session main workers vector. Also uses vec_elt_at_index() when accessing session main workers vector elements to catch those errors more easily. Type: fix Change-Id: I6059116b7b64ae6b26ad83c1fcf55df8522868ad Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/hs_apps/echo_client.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c
index 14d47be7422..9881cf40646 100644
--- a/src/plugins/hs_apps/echo_client.c
+++ b/src/plugins/hs_apps/echo_client.c
@@ -373,7 +373,6 @@ static int
ec_init (vlib_main_t *vm)
{
ec_main_t *ecm = &ec_main;
- vlib_thread_main_t *vtm = vlib_get_thread_main ();
ec_worker_t *wrk;
u32 num_threads;
int i;
@@ -414,8 +413,8 @@ ec_init (vlib_main_t *vm)
for (i = 0; i < vec_len (ecm->connect_test_data); i++)
ecm->connect_test_data[i] = i & 0xff;
- num_threads = 1 /* main thread */ + vtm->n_threads;
- vec_validate (ecm->wrk, num_threads);
+ num_threads = 1 /* main thread */ + vlib_num_workers ();
+ vec_validate (ecm->wrk, num_threads - 1);
vec_foreach (wrk, ecm->wrk)
{
vec_validate (wrk->rx_buf, vec_len (ecm->connect_test_data) - 1);
@@ -431,8 +430,8 @@ ec_init (vlib_main_t *vm)
vlib_worker_thread_barrier_release (vm);
/* Turn on the builtin client input nodes */
- for (i = 0; i < vtm->n_vlib_mains; i++)
- vlib_node_set_state (vlib_get_main_by_index (i), echo_clients_node.index,
+ foreach_vlib_main ()
+ vlib_node_set_state (this_vlib_main, echo_clients_node.index,
VLIB_NODE_STATE_POLLING);
return 0;