aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-10-02 19:36:57 +0200
committerDave Barach <openvpp@barachs.net>2020-11-09 11:51:34 +0000
commit9a3973e3a36bfd4dd8dbffe130a92649fc1b73d3 (patch)
tree1ed9e9c7a3b13edd68f7e78d66dbb995cbe79a2a /src/vnet/devices
parentf6b02e0d0bfd7e0f1d79e8ee426f48ca37ae5ff3 (diff)
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>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/af_packet/node.c6
-rw-r--r--src/vnet/devices/virtio/node.c5
-rw-r--r--src/vnet/devices/virtio/vhost_user_input.c28
3 files changed, 20 insertions, 19 deletions
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 196c0882bde..61d4ce2d1f5 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -310,11 +310,11 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* trace */
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (first_b0);
- if (PREDICT_FALSE (n_trace > 0))
+ if (PREDICT_FALSE
+ (n_trace > 0 && vlib_trace_buffer (vm, node, next0, first_b0,
+ /* follow_chain */ 0)))
{
af_packet_input_trace_t *tr;
- vlib_trace_buffer (vm, node, next0, first_b0, /* follow_chain */
- 0);
vlib_set_trace_count (vm, node, --n_trace);
tr = vlib_add_trace (vm, node, first_b0, sizeof (*tr));
tr->next_index = next0;
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c
index 94bf097df55..91e788e4d28 100644
--- a/src/vnet/devices/virtio/node.c
+++ b/src/vnet/devices/virtio/node.c
@@ -388,11 +388,10 @@ virtio_device_input_gso_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
/* trace */
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
- if (PREDICT_FALSE (n_trace > 0))
+ if (PREDICT_FALSE (n_trace > 0 && vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */
+ 1)))
{
virtio_input_trace_t *tr;
- vlib_trace_buffer (vm, node, next0, b0,
- /* follow_chain */ 1);
vlib_set_trace_count (vm, node, --n_trace);
tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
tr->next_index = next0;
diff --git a/src/vnet/devices/virtio/vhost_user_input.c b/src/vnet/devices/virtio/vhost_user_input.c
index da4937b733c..53230a61bc7 100644
--- a/src/vnet/devices/virtio/vhost_user_input.c
+++ b/src/vnet/devices/virtio/vhost_user_input.c
@@ -540,10 +540,10 @@ vhost_user_if_input (vlib_main_t * vm,
b_head->total_length_not_including_first_buffer = 0;
b_head->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
- if (PREDICT_FALSE (n_trace))
+ if (PREDICT_FALSE
+ (n_trace > 0 && vlib_trace_buffer (vm, node, next_index, b_head,
+ /* follow_chain */ 0)))
{
- vlib_trace_buffer (vm, node, next_index, b_head,
- /* follow_chain */ 0);
vhost_trace_t *t0 =
vlib_add_trace (vm, node, b_head, sizeof (t0[0]));
vhost_user_rx_trace (t0, vui, qid, b_head, txvq, last_avail_idx);
@@ -1362,17 +1362,19 @@ vhost_user_if_input_packed (vlib_main_t * vm, vhost_user_main_t * vum,
b = cpu->rx_buffers_pdesc;
while (n_trace && left)
{
- vhost_trace_t *t0;
-
- vlib_trace_buffer (vm, node, next_index, b[0],
- /* follow_chain */ 0);
- t0 = vlib_add_trace (vm, node, b[0], sizeof (t0[0]));
- b++;
- vhost_user_rx_trace_packed (t0, vui, qid, txvq, last_used_idx);
- last_used_idx = (last_used_idx + 1) & mask;
- n_trace--;
+ if (PREDICT_TRUE
+ (vlib_trace_buffer
+ (vm, node, next_index, b[0], /* follow_chain */ 0)))
+ {
+ vhost_trace_t *t0;
+ t0 = vlib_add_trace (vm, node, b[0], sizeof (t0[0]));
+ vhost_user_rx_trace_packed (t0, vui, qid, txvq, last_used_idx);
+ last_used_idx = (last_used_idx + 1) & mask;
+ n_trace--;
+ vlib_set_trace_count (vm, node, n_trace);
+ }
left--;
- vlib_set_trace_count (vm, node, n_trace);
+ b++;
}
}