vlib: fix trace number accounting
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 <bganne@cisco.com>
diff --git a/src/vnet/ethernet/p2p_ethernet_input.c b/src/vnet/ethernet/p2p_ethernet_input.c
index 7e5f7ca..3e9589e 100644
--- a/src/vnet/ethernet/p2p_ethernet_input.c
+++ b/src/vnet/ethernet/p2p_ethernet_input.c
@@ -119,11 +119,12 @@
vnet_buffer (b0)->sw_if_index[VLIB_RX] = rx0;
n_p2p_ethernet_packets += 1;
- if (PREDICT_FALSE (n_trace > 0))
+ if (PREDICT_FALSE
+ (n_trace > 0
+ && vlib_trace_buffer (vm, node, next_index, b0,
+ 1 /* follow_chain */ )))
{
p2p_ethernet_trace_t *t0;
- vlib_trace_buffer (vm, node, next_index, b0,
- 1 /* follow_chain */ );
vlib_set_trace_count (vm, node, --n_trace);
t0 = vlib_add_trace (vm, node, b0, sizeof (*t0));
t0->sw_if_index = sw_if_index0;
@@ -140,11 +141,12 @@
vnet_buffer (b1)->sw_if_index[VLIB_RX] = rx1;
n_p2p_ethernet_packets += 1;
- if (PREDICT_FALSE (n_trace > 0))
+ if (PREDICT_FALSE
+ (n_trace > 0
+ && vlib_trace_buffer (vm, node, next_index, b1,
+ 1 /* follow_chain */ )))
{
p2p_ethernet_trace_t *t1;
- vlib_trace_buffer (vm, node, next_index, b1,
- 1 /* follow_chain */ );
vlib_set_trace_count (vm, node, --n_trace);
t1 = vlib_add_trace (vm, node, b1, sizeof (*t1));
t1->sw_if_index = sw_if_index1;
@@ -195,11 +197,12 @@
vnet_buffer (b0)->sw_if_index[VLIB_RX] = rx0;
n_p2p_ethernet_packets += 1;
- if (PREDICT_FALSE (n_trace > 0))
+ if (PREDICT_FALSE
+ (n_trace > 0
+ && vlib_trace_buffer (vm, node, next_index, b0,
+ 1 /* follow_chain */ )))
{
p2p_ethernet_trace_t *t0;
- vlib_trace_buffer (vm, node, next_index, b0,
- 1 /* follow_chain */ );
vlib_set_trace_count (vm, node, --n_trace);
t0 = vlib_add_trace (vm, node, b0, sizeof (*t0));
t0->sw_if_index = sw_if_index0;
@@ -228,6 +231,7 @@
vlib_node_increment_counter (vm, p2p_ethernet_input_node.index,
P2PE_ERROR_HITS, n_p2p_ethernet_packets);
+
return frame->n_vectors;
}