From a8f4ebd08e6d7fddf6fca4f2ef7081321c51a451 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 8 Feb 2021 07:56:22 -0500 Subject: vlib: ASSERT vm == vlib_get_main() To catch coding mistakes: calling vlib_get_frame_to_node() from a worker thread with vm = &vlib_global_main instead of vm = vlib_mains[worker_thread_index] Type: improvement Signed-off-by: Dave Barach Change-Id: I5a8f01fdf9f35daeeada2d6eaa7180a60c4ca529 --- src/vlib/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vlib/main.c b/src/vlib/main.c index 77c69794d0f..761d4ee0bc5 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -122,6 +122,8 @@ vlib_frame_alloc_to_node (vlib_main_t * vm, u32 to_node_index, vlib_frame_t *f; u32 l, n, scalar_size, vector_size; + ASSERT (vm == vlib_get_main ()); + to_node = vlib_get_node (vm, to_node_index); scalar_size = to_node->scalar_size; @@ -221,6 +223,8 @@ vlib_put_frame_to_node (vlib_main_t * vm, u32 to_node_index, vlib_frame_t * f) if (f->n_vectors == 0) return; + ASSERT (vm == vlib_get_main ()); + vlib_validate_frame_indices (f); to_node = vlib_get_node (vm, to_node_index); @@ -241,6 +245,7 @@ vlib_frame_free (vlib_main_t * vm, vlib_node_runtime_t * r, vlib_frame_t * f) vlib_node_t *node; vlib_frame_size_t *fs; + ASSERT (vm == vlib_get_main ()); ASSERT (f->frame_flags & VLIB_FRAME_IS_ALLOCATED); node = vlib_get_node (vm, r->node_index); -- cgit 1.2.3-korg