37 s =
format (s,
"SPAN: mirrored %U -> %U",
44 #define foreach_span_error \ 45 _(HITS, "SPAN incoming packets processed") 49 #define _(sym,str) SPAN_ERROR_##sym, 56 #define _(sym,string) string, 69 u32 *to_mirror_next = 0;
90 if (mirror_frames[i] == 0)
92 if (sf == SPAN_FEAT_L2)
93 mirror_frames[i] = vlib_get_frame_to_node (vm, l2output_node.index);
95 mirror_frames[i] = vnet_get_frame_to_sw_interface (vnm, i);
104 c0->
flags |= VNET_BUFFER_F_SPAN_CLONE;
106 vnet_buffer (c0)->l2.feature_bitmap = L2OUTPUT_FEAT_OUTPUT;
120 c0->
flags |= VLIB_BUFFER_IS_TRACED;
135 u32 n_left_from, *from, *to_next;
147 while (n_left_from > 0)
153 while (n_left_from >= 4 && n_left_to_next >= 2)
165 to_next[0] = bi0 = from[0];
166 to_next[1] = bi1 = from[1];
174 sw_if_index0 =
vnet_buffer (b0)->sw_if_index[rxtx];
175 sw_if_index1 =
vnet_buffer (b1)->sw_if_index[rxtx];
177 span_mirror (vm, node, sw_if_index0, b0, mirror_frames, rxtx, sf);
178 span_mirror (vm, node, sw_if_index1, b1, mirror_frames, rxtx, sf);
207 to_next, n_left_to_next,
208 bi0, bi1, next0, next1);
210 while (n_left_from > 0 && n_left_to_next > 0)
218 to_next[0] = bi0 = from[0];
225 sw_if_index0 =
vnet_buffer (b0)->sw_if_index[rxtx];
227 span_mirror (vm, node, sw_if_index0, b0, mirror_frames, rxtx, sf);
247 n_left_to_next, bi0, next0);
254 for (sw_if_index = 0; sw_if_index <
vec_len (mirror_frames); sw_if_index++)
296 #define span_node_defs \ 297 .vector_size = sizeof (u32), \ 298 .format_trace = format_span_trace, \ 299 .type = VLIB_NODE_TYPE_INTERNAL, \ 300 .n_errors = ARRAY_LEN(span_error_strings), \ 301 .error_strings = span_error_strings, \ 310 .name =
"span-input",
315 .name =
"span-output",
320 .name =
"span-l2-input",
325 .name =
"span-l2-output",
328 #ifndef CLIB_MARCH_VARIANT 355 #undef span_node_defs
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static_always_inline uword span_node_inline_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, vlib_rx_or_tx_t rxtx, span_feat_t sf)
char ** l2output_get_feat_names(void)
span_mirror_t mirror_rxtx[SPAN_FEAT_N][VLIB_N_RX_TX]
vnet_main_t * vnet_get_main(void)
vlib_node_registration_t l2output_node
(constructor) VLIB_REGISTER_NODE (l2output_node)
clib_error_t * span_init(vlib_main_t *vm)
vlib_node_registration_t span_output_node
(constructor) VLIB_REGISTER_NODE (span_output_node)
#define VLIB_NODE_FN(node)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
format_function_t format_vnet_sw_if_index_name
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
static u32 vnet_l2_feature_next(vlib_buffer_t *b, u32 *next_nodes, u32 feat_bit)
Return the graph node index for the feature corresponding to the next set bit after clearing the curr...
clib_bitmap_t * mirror_ports
#define static_always_inline
static u8 * format_span_trace(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
span_interface_t * interfaces
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
vlib_node_registration_t span_input_node
(constructor) VLIB_REGISTER_NODE (span_input_node)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define VLIB_REGISTER_NODE(x,...)
static void vnet_put_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index, vlib_frame_t *f)
sll srl srl sll sra u16x4 i
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_main_t vlib_node_runtime_t * node
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define foreach_span_error
static_always_inline void span_mirror(vlib_main_t *vm, vlib_node_runtime_t *node, u32 sw_if_index0, vlib_buffer_t *b0, vlib_frame_t **mirror_frames, vlib_rx_or_tx_t rxtx, span_feat_t sf)
vlib_node_registration_t span_l2_input_node
(constructor) VLIB_REGISTER_NODE (span_l2_input_node)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static char * span_error_strings[]
#define CLIB_CACHE_LINE_BYTES
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vl_api_interface_index_t sw_if_index
vlib_node_registration_t span_l2_output_node
(constructor) VLIB_REGISTER_NODE (span_l2_output_node)