SPAN: Add pending frame on current thread, not on main
Previously, all frames were put for next node on the main thread,
even if the execution was happening on a worker thread.
Also, refactor to use API function vnet_get_main()
@@ -33,7 +33,7 @@ format_span_trace (u8 * s, va_list * args)
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
span_trace_t *t = va_arg (*args, span_trace_t *);
- vnet_main_t *vnm = &vnet_main;
+ vnet_main_t *vnm = vnet_get_main ();
s = format (s, "SPAN: mirrored %U -> %U",
format_vnet_sw_if_index_name, vnm, t->src_sw_if_index,
format_vnet_sw_if_index_name, vnm, t->mirror_sw_if_index);
@@ -65,7 +65,7 @@ span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0,
{
vlib_buffer_t *c0;
span_main_t *sm = &span_main;
- vnet_main_t *vnm = &vnet_main;
+ vnet_main_t *vnm = vnet_get_main ();
u32 *to_mirror_next = 0;
u32 i;
span_interface_t *si0;
@@ -90,8 +90,7 @@ span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0,
if (mirror_frames[i] == 0)
{
if (sf == SPAN_FEAT_L2)
- mirror_frames[i] = vlib_get_frame_to_node (vnm->vlib_main,
- l2output_node.index);
+ mirror_frames[i] = vlib_get_frame_to_node (vm, l2output_node.index);
else
mirror_frames[i] = vnet_get_frame_to_sw_interface (vnm, i);
}
@@ -132,7 +131,7 @@ span_node_inline_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
span_feat_t sf)
{
span_main_t *sm = &span_main;
- vnet_main_t *vnm = &vnet_main;
+ vnet_main_t *vnm = vnet_get_main ();
u32 n_left_from, *from, *to_next;
u32 next_index;
u32 sw_if_index;
@@ -259,7 +258,7 @@ span_node_inline_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
continue;
if (sf == SPAN_FEAT_L2)
- vlib_put_frame_to_node (vnm->vlib_main, l2output_node.index, f);
+ vlib_put_frame_to_node (vm, l2output_node.index, f);
else
vnet_put_frame_to_sw_interface (vnm, sw_if_index, f);
mirror_frames[sw_if_index] = 0;
