From f91080c01104a5999fe6c08e699b3426fea62dad Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 26 Jul 2018 12:27:27 -0400 Subject: Clean up dpdk plugin rx/tx pcap tracing Needed a spinlock to protect the data vector. Cleaned up debug cli so the output makes sense, and so that various parameters exist in one place. Removed a nonsense memset-to-zero which led to ultra-confusing results. Change-Id: I91cd14ce7fe84fd2eceab86e016b5ee001993be4 Signed-off-by: Dave Barach --- src/vnet/unix/pcap.c | 1 + src/vnet/unix/pcap.h | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'src/vnet/unix') diff --git a/src/vnet/unix/pcap.c b/src/vnet/unix/pcap.c index 473430a670e..e91b8792c2a 100644 --- a/src/vnet/unix/pcap.c +++ b/src/vnet/unix/pcap.c @@ -110,6 +110,7 @@ pcap_write (pcap_main_t * pm) pm->flags |= PCAP_MAIN_INIT_DONE; pm->n_packets_captured = 0; pm->n_pcap_data_written = 0; + clib_spinlock_init (&pm->lock); /* Write file header. */ memset (&fh, 0, sizeof (fh)); diff --git a/src/vnet/unix/pcap.h b/src/vnet/unix/pcap.h index 1ab1531cfa3..2c174fbedf9 100644 --- a/src/vnet/unix/pcap.h +++ b/src/vnet/unix/pcap.h @@ -123,6 +123,9 @@ typedef struct */ typedef struct { + /** spinlock to protect e.g. pcap_data */ + clib_spinlock_t lock; + /** File name of pcap output. */ char *file_name; @@ -213,6 +216,7 @@ pcap_add_buffer (pcap_main_t * pm, if (PREDICT_TRUE (pm->n_packets_captured < pm->n_packets_to_capture)) { + clib_spinlock_lock_if_init (&pm->lock); d = pcap_add_packet (pm, time_now, n_left, n); while (1) { @@ -225,6 +229,7 @@ pcap_add_buffer (pcap_main_t * pm, ASSERT (b->flags & VLIB_BUFFER_NEXT_PRESENT); b = vlib_get_buffer (vm, b->next_buffer); } + clib_spinlock_unlock_if_init (&pm->lock); } } -- cgit 1.2.3-korg