您好,登錄后才能下訂單哦!
可以通過開啟宏VLIB_BUFFER_TRACE_TRAJECTORY,在mbuf里記錄mbuf經過的node個數以及所經過的node的index:
if (VLIB_BUFFER_TRACE_TRAJECTORY && frame)
{
int i;
int log_index;
u32 * from;
from = vlib_frame_vector_args (frame);
for (i = 0; i < frame->n_vectors; i++)
{
vlib_buffer_t *b = vlib_get_buffer (vm, from[i]);
ASSERT (b->pre_data[0] < 32);
log_index = b->pre_data[0]++ + 1;
b->pre_data[log_index] = node->node_index;
}
n = node->function (vm, node, frame);
}
用以下函數打印記錄的node信息
void vlib_dump_context_trace (vlib_main_t*vm, u32 bi)
{
vlib_node_main_t * vnm = &vm->node_main;
vlib_buffer_t * b;
u8 i, n;
if (VLIB_BUFFER_TRACE_TRAJECTORY)
{
b = vlib_get_buffer (vm, bi);
n = b->pre_data[0];
fformat(stderr, "Context trace for bi %d b 0x%llx, visited%d\n",
bi, b, n);
if (n == 0 || n > 20)
{
fformat(stderr, "n is unreasonable\n");
return;
}
for (i = 0; i < n; i++)
{
u32 node_index;
node_index = b->pre_data[i+1];
if (node_index > vec_len (vnm->nodes))
{
fformat(stderr, "Skip bogusnode index %d\n", node_index);
continue;
}
fformat(stderr, "%v (%d)\n",vnm->nodes[node_index]->name,
node_index);
}
}
else
{
fformat(stderr,
"in vlib/buffers.h,#define VLIB_BUFFER_TRACE_TRAJECTORY 1\n");
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。