From f8b8586b699bae9e786726f2697c3e642d904c61 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Fri, 17 Aug 2018 18:29:07 -0400 Subject: Clean up packet tracer, especially "clear trace" There are multiple trace enablement schemes. It's easy to end up in vlib_add_trace with tracing disabled insofar as the packet tracer is concerned. When that happens, return the address of a per-system dummy trace record. Change-Id: I929391b8be4ed57e26e291afdc509a15f09a3160 Signed-off-by: Dave Barach --- src/vlib/trace_funcs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/vlib/trace_funcs.h') diff --git a/src/vlib/trace_funcs.h b/src/vlib/trace_funcs.h index 5280eae9904..eb06799305c 100644 --- a/src/vlib/trace_funcs.h +++ b/src/vlib/trace_funcs.h @@ -40,6 +40,8 @@ #ifndef included_vlib_trace_funcs_h #define included_vlib_trace_funcs_h +extern u8 *vnet_trace_dummy; + always_inline void vlib_validate_trace (vlib_trace_main_t * tm, vlib_buffer_t * b) { @@ -59,6 +61,14 @@ vlib_add_trace (vlib_main_t * vm, vlib_trace_header_t *h; u32 n_data_words; + ASSERT (vnet_trace_dummy); + + if (PREDICT_FALSE (tm->trace_enable == 0)) + { + ASSERT (vec_len (vnet_trace_dummy) >= n_data_bytes + sizeof (*h)); + return vnet_trace_dummy; + } + vlib_validate_trace (tm, b); n_data_bytes = round_pow2 (n_data_bytes, sizeof (h[0])); @@ -108,6 +118,9 @@ vlib_trace_buffer (vlib_main_t * vm, vlib_trace_main_t *tm = &vm->trace_main; vlib_trace_header_t **h; + if (PREDICT_FALSE (tm->trace_enable == 0)) + return; + /* * Apply filter to existing traces to keep number of allocated traces low. * Performed each time around the main loop. -- cgit 1.2.3-korg