summaryrefslogtreecommitdiffstats
path: root/src/plugins
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/plugins
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/plugins')
-rw-r--r--src/plugins/af_xdp/input.c24
-rw-r--r--src/plugins/avf/input.c28
-rw-r--r--src/plugins/dpdk/device/node.c37
-rw-r--r--src/plugins/dpdk/ipsec/crypto_node.c16
-rw-r--r--src/plugins/memif/node.c19
-rw-r--r--src/plugins/rdma/input.c27
-rw-r--r--src/plugins/vmxnet3/input.c23
7 files changed, 94 insertions, 80 deletions
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++;
}
diff --git a/src/plugins/avf/input.c b/src/plugins/avf/input.c
index 9d677ab96d5..4e4f116304d 100644
--- a/src/plugins/avf/input.c
+++ b/src/plugins/avf/input.c
@@ -383,20 +383,24 @@ no_more_desc:
while (n_trace && n_left)
{
- vlib_buffer_t *b;
- avf_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->qid = qid;
- tr->hw_if_index = ad->hw_if_index;
- tr->qw1s[0] = ptd->qw1s[i];
- for (j = 1; j < AVF_RX_MAX_DESC_IN_CHAIN; j++)
- tr->qw1s[j] = ptd->tails[i].qw1s[j - 1];
+ vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]);
+ if (PREDICT_TRUE
+ (vlib_trace_buffer
+ (vm, node, next_index, b, /* follow_chain */ 0)))
+ {
+ avf_input_trace_t *tr =
+ vlib_add_trace (vm, node, b, sizeof (*tr));
+ tr->next_index = next_index;
+ tr->qid = qid;
+ tr->hw_if_index = ad->hw_if_index;
+ tr->qw1s[0] = ptd->qw1s[i];
+ for (j = 1; j < AVF_RX_MAX_DESC_IN_CHAIN; j++)
+ tr->qw1s[j] = ptd->tails[i].qw1s[j - 1];
+
+ n_trace--;
+ }
/* next */
- n_trace--;
n_left--;
bi++;
i++;
diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c
index 256c399ea32..e7d836fe0f8 100644
--- a/src/plugins/dpdk/device/node.c
+++ b/src/plugins/dpdk/device/node.c
@@ -417,21 +417,28 @@ dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
b0 = vlib_get_buffer (vm, buffers[0]);
if (single_next == 0)
next_index = next[0];
- vlib_trace_buffer (vm, node, next_index, b0, /* follow_chain */ 0);
-
- dpdk_rx_trace_t *t0 = vlib_add_trace (vm, node, b0, sizeof t0[0]);
- t0->queue_index = queue_id;
- t0->device_index = xd->device_index;
- t0->buffer_index = vlib_get_buffer_index (vm, b0);
-
- clib_memcpy_fast (&t0->mb, mb[0], sizeof t0->mb);
- clib_memcpy_fast (&t0->buffer, b0,
- sizeof b0[0] - sizeof b0->pre_data);
- clib_memcpy_fast (t0->buffer.pre_data, b0->data,
- sizeof t0->buffer.pre_data);
- clib_memcpy_fast (&t0->data, mb[0]->buf_addr + mb[0]->data_off,
- sizeof t0->data);
- n_trace--;
+
+ if (PREDICT_TRUE
+ (vlib_trace_buffer
+ (vm, node, next_index, b0, /* follow_chain */ 0)))
+ {
+
+ dpdk_rx_trace_t *t0 =
+ vlib_add_trace (vm, node, b0, sizeof t0[0]);
+ t0->queue_index = queue_id;
+ t0->device_index = xd->device_index;
+ t0->buffer_index = vlib_get_buffer_index (vm, b0);
+
+ clib_memcpy_fast (&t0->mb, mb[0], sizeof t0->mb);
+ clib_memcpy_fast (&t0->buffer, b0,
+ sizeof b0[0] - sizeof b0->pre_data);
+ clib_memcpy_fast (t0->buffer.pre_data, b0->data,
+ sizeof t0->buffer.pre_data);
+ clib_memcpy_fast (&t0->data, mb[0]->buf_addr + mb[0]->data_off,
+ sizeof t0->data);
+ n_trace--;
+ }
+
n_left--;
buffers++;
mb++;
diff --git a/src/plugins/dpdk/ipsec/crypto_node.c b/src/plugins/dpdk/ipsec/crypto_node.c
index 76e57a3228a..893848c05b6 100644
--- a/src/plugins/dpdk/ipsec/crypto_node.c
+++ b/src/plugins/dpdk/ipsec/crypto_node.c
@@ -106,14 +106,16 @@ dpdk_crypto_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
b0 = vlib_get_buffer (vm, bi);
- vlib_trace_buffer (vm, node, next, b0, /* follow_chain */ 0);
+ if (PREDICT_TRUE
+ (vlib_trace_buffer (vm, node, next, b0, /* follow_chain */ 0)))
+ {
+ dpdk_crypto_input_trace_t *tr =
+ vlib_add_trace (vm, node, b0, sizeof (*tr));
+ tr->dev_id = dev_id;
+ tr->next_index = next;
+ n_trace--;
+ }
- dpdk_crypto_input_trace_t *tr =
- vlib_add_trace (vm, node, b0, sizeof (*tr));
- tr->dev_id = dev_id;
- tr->next_index = next;
-
- n_trace--;
n_left--;
nexts++;
bis++;
diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c
index 82a7cbc142c..506d88af76d 100644
--- a/src/plugins/memif/node.c
+++ b/src/plugins/memif/node.c
@@ -92,10 +92,10 @@ memif_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
{
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
- if (PREDICT_TRUE (b != 0))
+ if (PREDICT_TRUE
+ (b != 0 && vlib_trace_buffer (vm, node, next, b, /* follow_chain */ 0)))
{
memif_input_trace_t *tr;
- vlib_trace_buffer (vm, node, next, b, /* follow_chain */ 0);
vlib_set_trace_count (vm, node, --(*n_tracep));
tr = vlib_add_trace (vm, node, b, sizeof (*tr));
tr->next_index = next;
@@ -484,14 +484,17 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
if (mode != MEMIF_INTERFACE_MODE_ETHERNET)
ni = next[0];
b = vlib_get_buffer (vm, bi[0]);
- vlib_trace_buffer (vm, node, ni, b, /* follow_chain */ 0);
- tr = vlib_add_trace (vm, node, b, sizeof (*tr));
- tr->next_index = ni;
- tr->hw_if_index = mif->hw_if_index;
- tr->ring = qid;
+ if (PREDICT_TRUE
+ (vlib_trace_buffer (vm, node, ni, b, /* follow_chain */ 0)))
+ {
+ tr = vlib_add_trace (vm, node, b, sizeof (*tr));
+ tr->next_index = ni;
+ tr->hw_if_index = mif->hw_if_index;
+ tr->ring = qid;
+ n_trace--;
+ }
/* next */
- n_trace--;
n_left--;
bi++;
next++;
diff --git a/src/plugins/rdma/input.c b/src/plugins/rdma/input.c
index 1d267ad6cc0..52e921dd172 100644
--- a/src/plugins/rdma/input.c
+++ b/src/plugins/rdma/input.c
@@ -225,30 +225,27 @@ rdma_device_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
const u32 * bi, u32 next_index, u16 * cqe_flags,
int is_mlx5dv)
{
- u32 n_trace, i;
+ 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;
- i = 0;
while (n_trace && n_left)
{
- vlib_buffer_t *b;
- rdma_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 = rd->hw_if_index;
- tr->cqe_flags = is_mlx5dv ? clib_net_to_host_u16 (cqe_flags[0]) : 0;
-
+ vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]);
+ if (PREDICT_TRUE
+ (vlib_trace_buffer (vm, node, next_index, b, /* follow_chain */ 0)))
+ {
+ rdma_input_trace_t *tr = vlib_add_trace (vm, node, b, sizeof (*tr));
+ tr->next_index = next_index;
+ tr->hw_if_index = rd->hw_if_index;
+ tr->cqe_flags = is_mlx5dv ? clib_net_to_host_u16 (cqe_flags[0]) : 0;
+ n_trace--;
+ }
/* next */
- n_trace--;
n_left--;
cqe_flags++;
bi++;
- i++;
}
vlib_set_trace_count (vm, node, n_trace);
}
diff --git a/src/plugins/vmxnet3/input.c b/src/plugins/vmxnet3/input.c
index f182409ac59..bed4c1e3292 100644
--- a/src/plugins/vmxnet3/input.c
+++ b/src/plugins/vmxnet3/input.c
@@ -418,17 +418,18 @@ vmxnet3_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
next = nexts;
while (n_trace && n_left)
{
- vlib_buffer_t *b;
- vmxnet3_input_trace_t *tr;
-
- b = vlib_get_buffer (vm, bi[0]);
- vlib_trace_buffer (vm, node, next[0], b, /* follow_chain */ 0);
- tr = vlib_add_trace (vm, node, b, sizeof (*tr));
- tr->next_index = next[0];
- tr->hw_if_index = vd->hw_if_index;
- tr->buffer = *b;
-
- n_trace--;
+ vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]);
+ if (PREDICT_TRUE
+ (vlib_trace_buffer
+ (vm, node, next[0], b, /* follow_chain */ 0)))
+ {
+ vmxnet3_input_trace_t *tr =
+ vlib_add_trace (vm, node, b, sizeof (*tr));
+ tr->next_index = next[0];
+ tr->hw_if_index = vd->hw_if_index;
+ tr->buffer = *b;
+ n_trace--;
+ }
n_left--;
bi++;
next++;