aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ethernet
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-02-25 15:27:28 -0500
committerDamjan Marion <dmarion@me.com>2019-02-26 11:30:29 +0000
commit5ecd5a5d159332a964dd840fcdabe5f8d3111b0e (patch)
tree99c6fbcd96efce44215bb06363126acfa88f8fb0 /src/vnet/ethernet
parentf6defa113e2e10a70c5a92ce7e14b7a532154409 (diff)
Move pcap rx/tx trace code out of the dpdk plugin
Moved code to the ethernet input node, and the interface output path(s). Since we no longer skip ethernet-input, there's no reason for device drivers to know anything about pcap rx tracing, etc. Change-Id: I08d32fb1b90cbee1bd4f609837d533e047b36fa4 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/ethernet')
-rwxr-xr-xsrc/vnet/ethernet/node.c59
1 files changed, 42 insertions, 17 deletions
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index 3264bdc03af..950a962217c 100755
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -963,29 +963,54 @@ ethernet_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame)
{
u32 *from, n_left;
- if ((node->flags & VLIB_NODE_FLAG_TRACE) == 0)
- return;
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) == 0))
+ {
+ from = vlib_frame_vector_args (from_frame);
+ n_left = from_frame->n_vectors;
- from = vlib_frame_vector_args (from_frame);
- n_left = from_frame->n_vectors;
+ while (n_left)
+ {
+ ethernet_input_trace_t *t0;
+ vlib_buffer_t *b0 = vlib_get_buffer (vm, from[0]);
- while (n_left)
+ if (b0->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ t0 = vlib_add_trace (vm, node, b0,
+ sizeof (ethernet_input_trace_t));
+ clib_memcpy_fast (t0->packet_data, b0->data + b0->current_data,
+ sizeof (t0->packet_data));
+ t0->frame_flags = from_frame->flags;
+ clib_memcpy_fast (&t0->frame_data,
+ vlib_frame_scalar_args (from_frame),
+ sizeof (ethernet_input_frame_t));
+ }
+ from += 1;
+ n_left -= 1;
+ }
+ }
+
+ /* rx pcap capture if enabled */
+ if (PREDICT_FALSE (vm->pcap[VLIB_RX].pcap_enable))
{
- ethernet_input_trace_t *t0;
- vlib_buffer_t *b0 = vlib_get_buffer (vm, from[0]);
+ u32 bi0;
- if (b0->flags & VLIB_BUFFER_IS_TRACED)
+ from = vlib_frame_vector_args (from_frame);
+ n_left = from_frame->n_vectors;
+ while (n_left > 0)
{
- t0 = vlib_add_trace (vm, node, b0, sizeof (ethernet_input_trace_t));
- clib_memcpy_fast (t0->packet_data, b0->data + b0->current_data,
- sizeof (t0->packet_data));
- t0->frame_flags = from_frame->flags;
- clib_memcpy_fast (&t0->frame_data,
- vlib_frame_scalar_args (from_frame),
- sizeof (ethernet_input_frame_t));
+ vlib_buffer_t *b0;
+ bi0 = from[0];
+ from++;
+ b0 = vlib_get_buffer (vm, bi0);
+
+ if (vm->pcap[VLIB_RX].pcap_sw_if_index == 0 ||
+ vm->pcap[VLIB_RX].pcap_sw_if_index
+ == vnet_buffer (b0)->sw_if_index[VLIB_RX])
+ {
+ pcap_add_buffer (&vm->pcap[VLIB_RX].pcap_main, vm, bi0, 512);
+ }
+ n_left--;
}
- from += 1;
- n_left -= 1;
}
}