diff options
Diffstat (limited to 'src/vlib/trace_funcs.h')
-rw-r--r-- | src/vlib/trace_funcs.h | 13 |
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. |