+ /*
+ * there is a small chance of a race condition with 'clear trace' here: if a
+ * buffer was set to be traced before the 'clear trace' and is still going
+ * through the graph after the 'clear trace', its trace_index is staled as
+ * the pool was destroyed.
+ * The pool may have been re-allocated because of a new traced buffer, and
+ * the trace_index might be valid by pure (bad) luck. In that case the trace
+ * will be a mix of both buffer traces, but this should be acceptable.
+ */
+ trace_index = vlib_buffer_get_trace_index (b);
+ if (PREDICT_FALSE (pool_is_free_index (tm->trace_buffer_pool, trace_index)))
+ return vnet_trace_placeholder;