6 #include <vpp/app/version.h> 24 #define VLIB_PCAP_MAJOR_VERSION 1 25 #define VLIB_PCAP_MINOR_VERSION 0 44 s =
format (s,
"current_data: %d, current_length: %d\n",
47 s,
"current_config_index/punt_reason: %d, flow_id: %x, next_buffer: %x\n",
49 s =
format (s,
"error: %d, ref_count: %d, buffer_pool_index: %d\n",
52 s =
format (s,
"trace_handle: 0x%x, len_not_first_buf: %d\n",
57 #define A(x) vec_add1 (dtt->pcap_buffer, (x)) 104 A ((from[i] >> 24) & 0xff);
105 A ((from[i] >> 16) & 0xff);
106 A ((from[i] >> 8) & 0xff);
107 A ((from[i] >> 0) & 0xff);
142 n_left =
clib_min (capture_size, 16384);
167 return node->
function (vm, node, frame);
198 (
char *)
format (0,
"/tmp/dispatch_post_mortem.%d%c", getpid (), 0);
225 "pcap dispatch capture enabled: %d of %d pkts...",
232 vm,
"Buffer trace of %d pkts from %U enabled...",
246 return VNET_API_ERROR_INVALID_VALUE;
250 return VNET_API_ERROR_VALUE_EXIST;
255 return VNET_API_ERROR_INVALID_VALUE_2;
262 tm = &this_vlib_main->trace_main;
275 clib_warning (0,
"Dispatch wrapper already in use on thread %u",
276 this_vlib_main->thread_index);
286 memset (pm, 0,
sizeof (*pm));
307 tm = &this_vlib_main->trace_main;
326 return VNET_API_ERROR_SYSCALL_ERROR_1;
331 return VNET_API_ERROR_NO_SUCH_ENTRY;
338 if (epoll_input_node)
371 if (
unformat (line_input,
"on %=", &enable, 1))
373 else if (
unformat (line_input,
"enable %=", &enable, 1))
375 else if (
unformat (line_input,
"off %=", &enable, 0))
377 else if (
unformat (line_input,
"disable %=", &enable, 0))
379 else if (
unformat (line_input,
"max %d", &max))
381 else if (
unformat (line_input,
"packets-to-capture %d", &max))
386 else if (
unformat (line_input,
"status %=", &status, 1))
389 vm, &node_index, &buffer_traces_to_capture))
391 else if (
unformat (line_input,
"post-mortem %=", &post_mortem, 1))
426 0,
"can't change number of records to capture while tracing...");
498 .path =
"pcap dispatch trace",
500 "pcap dispatch trace [on|off] [max <nn>] [file <name>] [status]\n" 501 " [buffer-trace <input-node-name> <nn>][post-mortem]",
506 .version = VPP_BUILD_VER,
507 .description =
"Dispatch Trace",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
char * file_name
File name of pcap output.
__clib_export clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
format_function_t format_vlib_node_name
u32 n_packets_to_capture
Number of packets to capture.
static u32 vlib_buffer_get_trace_index(vlib_buffer_t *b)
Extract the trace (pool) index from a trace handle.
vlib_trace_node_t * nodes
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
clib_spinlock_t worker_thread_main_loop_callback_lock
static f64 vlib_time_now(vlib_main_t *vm)
#define VLIB_PCAP_MINOR_VERSION
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
u16 current_length
Nbytes between current data and the end of this buffer.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
dispatch_trace_thread_t * threads
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
u8 buffer_pool_index
index of buffer pool this buffer belongs.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define foreach_vlib_main()
u32 input_main_loops_per_call
For input nodes: decremented on each main loop interation until it reaches zero and function is calle...
u32 * dispatch_buffer_trace_nodes
vlib_trace_header_t ** trace_buffer_pool
PCAP main state data structure.
clib_spinlock_t lock
spinlock to protect e.g.
vlib_node_function_t * function
Node function to call.
dispatch_trace_main_t dispatch_trace_main
vlib_get_buffers(vm, from, b, n_left_from)
static int vlib_pcap_dispatch_trace_configure(vlib_pcap_dispatch_trace_args_t *a)
description fragment has unexpected format
u32 buffer_trace_node_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
format_function_t format_vnet_buffer_opaque2
u8 * vnet_trace_placeholder
static void clib_spinlock_init(clib_spinlock_t *p)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
u32 epoll_input_node_index
format_function_t format_vnet_buffer_flags
__clib_export clib_error_t * pcap_close(pcap_main_t *pm)
Close PCAP file.
vlib_worker_thread_t * vlib_worker_threads
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
format_function_t format_vnet_buffer_opaque
void(**volatile worker_thread_main_loop_callback_tmp)(struct vlib_main_t *, u64 t)
format_function_t format_vlib_trace
u8 * pcap_data
Vector of pcap data.
u32 trace_handle
Specifies trace buffer handle if VLIB_PACKET_IS_TRACED flag is set.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
u32 node_index
Node index.
static u8 * format_buffer_metadata(u8 *s, va_list *args)
static void * pcap_add_packet(pcap_main_t *pm, f64 time_now, u32 n_bytes_in_trace, u32 n_bytes_in_packet)
Add packet.
static clib_error_t * dispatch_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void pcap_postmortem_dump(void)
u32 flow_id
Generic flow identifier.
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
#define FILTER_FLAG_POST_MORTEM
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
void(**volatile worker_thread_main_loop_callbacks)(struct vlib_main_t *, u64 t)
#define VLIB_PCAP_MAJOR_VERSION
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
static int vlib_node_set_dispatch_wrapper(vlib_main_t *vm, vlib_node_function_t *fn)
#define VLIB_CLI_COMMAND(x,...)
#define PCAP_MAIN_INIT_DONE
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u32 buffer_traces_to_capture
#define clib_callback_enable_disable(h, tmp, l, f, enable)
Add or remove a callback to the specified callback set.
#define clib_error_report(e)
vlib_trace_main_t trace_main
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static vlib_main_t * vlib_get_main(void)
pcap_packet_type_t packet_type
Packet type.
void vlib_add_del_post_mortem_callback(void *cb, int is_add)
uword dispatch_pcap_trace(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_main_t vlib_node_runtime_t * node
u32 next_buffer
Next buffer for this linked-list of buffers.
pcap_main_t dispatch_pcap_main
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
unformat_function_t unformat_vlib_node
static vlib_thread_main_t * vlib_get_thread_main()
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define CLIB_CACHE_LINE_BYTES
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
static void pcap_postmortem_reset(vlib_main_t *vm)
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
volatile u8 ref_count
Reference count for this buffer.
u32 n_packets_captured
Number of packets currently captured.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.