summaryrefslogtreecommitdiffstats
path: root/src/vlib/main.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-03-04 14:31:03 +0100
committerDamjan Marion <dmarion@me.com>2021-05-01 11:42:37 +0000
commitf89bbbe300dad7bc479db535e7822199f98aca30 (patch)
tree1163eeac010375a962fcda8c2e0c7a7046161bf1 /src/vlib/main.c
parentc8983241b9d93d2c3b60b0705efbc3cdee54c534 (diff)
vlib: refactor trajectory trace debug feature
trajectory trace has been broken for a while because we used to save the buffer trajectory in a vector pointed to in opaque2. This does not work well when opaque2 is copied (eg. because of a clone) as 2 buffers end up sharing the same vector. This dedicates a full cacheline in the buffer metadata instead when trajectory is compiled in. No dynamic allocation, no sharing, no tears. Type: refactor Change-Id: I6a028ca1b48d38f393a36979e5e452c2dd48ad3f Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vlib/main.c')
-rw-r--r--src/vlib/main.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index bee63970f3d..f833aa25acf 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -934,29 +934,14 @@ vlib_elog_main_loop_event (vlib_main_t * vm,
}
}
-#if VLIB_BUFFER_TRACE_TRAJECTORY > 0
-void (*vlib_buffer_trace_trajectory_cb) (vlib_buffer_t * b, u32 node_index);
-void (*vlib_buffer_trace_trajectory_init_cb) (vlib_buffer_t * b);
-
-void
-vlib_buffer_trace_trajectory_init (vlib_buffer_t * b)
-{
- if (PREDICT_TRUE (vlib_buffer_trace_trajectory_init_cb != 0))
- {
- (*vlib_buffer_trace_trajectory_init_cb) (b);
- }
-}
-
-#endif
-
static inline void
add_trajectory_trace (vlib_buffer_t * b, u32 node_index)
{
#if VLIB_BUFFER_TRACE_TRAJECTORY > 0
- if (PREDICT_TRUE (vlib_buffer_trace_trajectory_cb != 0))
- {
- (*vlib_buffer_trace_trajectory_cb) (b, node_index);
- }
+ if (PREDICT_FALSE (b->trajectory_nb >= VLIB_BUFFER_TRACE_TRAJECTORY_MAX))
+ return;
+ b->trajectory_trace[b->trajectory_nb] = node_index;
+ b->trajectory_nb++;
#endif
}