summaryrefslogtreecommitdiffstats
path: root/src/vnet/pg/output.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-02-03 21:16:16 +0100
committerDamjan Marion <damarion@cisco.com>2017-02-03 21:16:16 +0100
commitbfe4dfa7089b5d2c03aa607ab72abbcd840cbbce (patch)
treef7f95f988229c70a45916367cfce104d0c27eb6c /src/vnet/pg/output.c
parent62411e7d82dc4562003651a53e723ea938be2ebd (diff)
pg: add trace information for pg tx node
Change-Id: I31730d58c34331f25f5b02cd065be94251f1302c Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/pg/output.c')
-rw-r--r--src/vnet/pg/output.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/vnet/pg/output.c b/src/vnet/pg/output.c
index 3d1f2660e20..ab57deefd24 100644
--- a/src/vnet/pg/output.c
+++ b/src/vnet/pg/output.c
@@ -37,6 +37,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <vppinfra/string.h>
#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vnet/pg/pg.h>
@@ -56,19 +57,28 @@ pg_output (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
while (__sync_lock_test_and_set (pif->lockp, 1))
;
- if (pif->pcap_file_name != 0)
+ while (n_left > 0)
{
- while (n_left > 0)
- {
- n_left--;
- u32 bi0 = buffers[0];
- buffers++;
+ n_left--;
+ u32 bi0 = buffers[0];
+ vlib_buffer_t *b = vlib_get_buffer (vm, bi0);
+ buffers++;
- pcap_add_buffer (&pif->pcap_main, vm, bi0,
- ETHERNET_MAX_PACKET_BYTES);
+ if (b->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ pg_output_trace_t *t = vlib_add_trace (vm, node, b, sizeof (*t));
+ t->buffer_index = bi0;
+ clib_memcpy (&t->buffer, b, sizeof (b[0]) - sizeof (b->pre_data));
+ clib_memcpy (t->buffer.pre_data, b->data + b->current_data,
+ sizeof (t->buffer.pre_data));
}
- pcap_write (&pif->pcap_main);
+
+ if (pif->pcap_file_name != 0)
+ pcap_add_buffer (&pif->pcap_main, vm, bi0, ETHERNET_MAX_PACKET_BYTES);
}
+ if (pif->pcap_file_name != 0)
+ pcap_write (&pif->pcap_main);
+
vlib_buffer_free (vm, vlib_frame_args (frame), n_buffers);
if (PREDICT_FALSE (pif->lockp != 0))