vlib: fix trace number accounting
[vpp.git] / src / vnet / devices / af_packet / node.c
index 85f3e01..61d4ce2 100644 (file)
@@ -310,11 +310,11 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
 
          /* trace */
          VLIB_BUFFER_TRACE_TRAJECTORY_INIT (first_b0);
-         if (PREDICT_FALSE (n_trace > 0))
+         if (PREDICT_FALSE
+             (n_trace > 0 && vlib_trace_buffer (vm, node, next0, first_b0,
+                                                /* follow_chain */ 0)))
            {
              af_packet_input_trace_t *tr;
-             vlib_trace_buffer (vm, node, next0, first_b0,     /* follow_chain */
-                                0);
              vlib_set_trace_count (vm, node, --n_trace);
              tr = vlib_add_trace (vm, node, first_b0, sizeof (*tr));
              tr->next_index = next0;
@@ -369,6 +369,7 @@ VLIB_NODE_FN (af_packet_input_node) (vlib_main_t * vm,
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (af_packet_input_node) = {
   .name = "af-packet-input",
+  .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
   .sibling_of = "device-input",
   .format_trace = format_af_packet_input_trace,
   .type = VLIB_NODE_TYPE_INPUT,