From 9a3973e3a36bfd4dd8dbffe130a92649fc1b73d3 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Fri, 2 Oct 2020 19:36:57 +0200 Subject: vlib: fix trace number accounting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using classifier to filter traces, not all packets will be traced. In that case, we should only count traced packets. Type: fix Change-Id: I87d1e217b580ebff8c6ade7860eb43950420ae78 Signed-off-by: Benoît Ganne --- src/plugins/af_xdp/input.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/plugins/af_xdp/input.c') diff --git a/src/plugins/af_xdp/input.c b/src/plugins/af_xdp/input.c index c164c2576b7..2cf121fb69d 100644 --- a/src/plugins/af_xdp/input.c +++ b/src/plugins/af_xdp/input.c @@ -46,23 +46,23 @@ af_xdp_device_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_left, const u32 * bi, u32 next_index, u32 hw_if_index) { - u32 n_trace; + u32 n_trace = vlib_get_trace_count (vm, node); - if (PREDICT_TRUE (0 == (n_trace = vlib_get_trace_count (vm, node)))) + if (PREDICT_TRUE (0 == n_trace)) return; while (n_trace && n_left) { - vlib_buffer_t *b; - af_xdp_input_trace_t *tr; - b = vlib_get_buffer (vm, bi[0]); - vlib_trace_buffer (vm, node, next_index, b, - /* follow_chain */ 0); - tr = vlib_add_trace (vm, node, b, sizeof (*tr)); - tr->next_index = next_index; - tr->hw_if_index = hw_if_index; - - n_trace--; + vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]); + if (PREDICT_TRUE + (vlib_trace_buffer (vm, node, next_index, b, /* follow_chain */ 0))) + { + af_xdp_input_trace_t *tr = + vlib_add_trace (vm, node, b, sizeof (*tr)); + tr->next_index = next_index; + tr->hw_if_index = hw_if_index; + n_trace--; + } n_left--; bi++; } -- cgit 1.2.3-korg