summaryrefslogtreecommitdiffstats
path: root/src/vlib/trace_funcs.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-08-17 18:29:07 -0400
committerDamjan Marion <dmarion@me.com>2018-08-24 19:03:12 +0000
commitf8b8586b699bae9e786726f2697c3e642d904c61 (patch)
treef8be5022a5e6b1ce80023be6b3a02d241f40b466 /src/vlib/trace_funcs.h
parenta9aedb681feb0a489b1b78435794081ecd5b88fc (diff)
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 <dave@barachs.net>
Diffstat (limited to 'src/vlib/trace_funcs.h')
-rw-r--r--src/vlib/trace_funcs.h13
1 files changed, 13 insertions, 0 deletions
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.