diff options
author | Dave Barach <dbarach@cisco.com> | 2018-05-25 17:36:05 -0400 |
---|---|---|
committer | Dave Barach <dbarach@cisco.com> | 2018-05-25 17:36:44 -0400 |
commit | c6f186b23d00685b3e9f132ba79a5cb44f0a44c0 (patch) | |
tree | cddcc7b7831e61f0f5d7b008a7ca1ae80e14f280 /src/vnet | |
parent | c65770deebf63d34cc09c6aa3af7c86b3affb4b8 (diff) |
Add interface rx pcap tracing
Should cost at most 1 clock per frame when not enabled.
Add "pcap rx trace..." debug CLI, refactored "pcap tx trace" debug CLI
to avoid duplicating code.
Change-Id: I19ac75d1cf94a6a24c98facbf0753381d37963ea
Signed-off-by: Dave Barach <dbarach@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/unix/pcap.h | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/vnet/unix/pcap.h b/src/vnet/unix/pcap.h index 7d55db37979..1ab1531cfa3 100644 --- a/src/vnet/unix/pcap.h +++ b/src/vnet/unix/pcap.h @@ -211,23 +211,21 @@ pcap_add_buffer (pcap_main_t * pm, f64 time_now = vlib_time_now (vm); void *d; - d = pcap_add_packet (pm, time_now, n_left, n); - while (1) + if (PREDICT_TRUE (pm->n_packets_captured < pm->n_packets_to_capture)) { - u32 copy_length = clib_min ((u32) n_left, b->current_length); - clib_memcpy (d, b->data + b->current_data, copy_length); - n_left -= b->current_length; - if (n_left <= 0) - break; - d += b->current_length; - ASSERT (b->flags & VLIB_BUFFER_NEXT_PRESENT); - b = vlib_get_buffer (vm, b->next_buffer); + d = pcap_add_packet (pm, time_now, n_left, n); + while (1) + { + u32 copy_length = clib_min ((u32) n_left, b->current_length); + clib_memcpy (d, b->data + b->current_data, copy_length); + n_left -= b->current_length; + if (n_left <= 0) + break; + d += b->current_length; + ASSERT (b->flags & VLIB_BUFFER_NEXT_PRESENT); + b = vlib_get_buffer (vm, b->next_buffer); + } } - - /** Flush output vector. */ - if (vec_len (pm->pcap_data) >= 64 * 1024 - || pm->n_packets_captured >= pm->n_packets_to_capture) - pcap_write (pm); } #endif /* included_vnet_pcap_h */ |