39 s =
format (s,
"SPAN: mirrored %U -> %U",
46 #define foreach_span_error \ 47 _(HITS, "SPAN incomming packets processed") 51 #define _(sym,str) SPAN_ERROR_##sym, 58 #define _(sym,string) string, 71 u32 *to_mirror_next = 0;
87 if (mirror_frames[i] == 0)
89 if (sf == SPAN_FEAT_L2)
90 mirror_frames[i] = vlib_get_frame_to_node (vnm->vlib_main, l2output_node.index);
92 mirror_frames[i] = vnet_get_frame_to_sw_interface (vnm, i);
101 c0->
flags |= VNET_BUFFER_F_SPAN_CLONE;
103 vnet_buffer (c0)->l2.feature_bitmap = L2OUTPUT_FEAT_OUTPUT;
124 u32 n_left_from, *from, *to_next;
125 u32 n_span_packets = 0;
137 while (n_left_from > 0)
143 while (n_left_from >= 4 && n_left_to_next >= 2)
155 to_next[0] = bi0 = from[0];
156 to_next[1] = bi1 = from[1];
164 sw_if_index0 =
vnet_buffer (b0)->sw_if_index[rxtx];
165 sw_if_index1 =
vnet_buffer (b1)->sw_if_index[rxtx];
167 span_mirror (vm, node, sw_if_index0, b0, mirror_frames, rxtx, sf);
168 span_mirror (vm, node, sw_if_index1, b1, mirror_frames, rxtx, sf);
197 to_next, n_left_to_next,
198 bi0, bi1, next0, next1);
200 while (n_left_from > 0 && n_left_to_next > 0)
208 to_next[0] = bi0 = from[0];
215 sw_if_index0 =
vnet_buffer (b0)->sw_if_index[rxtx];
217 span_mirror (vm, node, sw_if_index0, b0, mirror_frames, rxtx, sf);
237 n_left_to_next, bi0, next0);
244 for (sw_if_index = 0; sw_if_index <
vec_len (mirror_frames); sw_if_index++)
254 mirror_frames[sw_if_index] = 0;
290 #define span_node_defs \ 291 .vector_size = sizeof (u32), \ 292 .format_trace = format_span_trace, \ 293 .type = VLIB_NODE_TYPE_INTERNAL, \ 294 .n_errors = ARRAY_LEN(span_error_strings), \ 295 .error_strings = span_error_strings, \ 305 .name =
"span-input",
313 .name =
"span-output",
321 .name =
"span-l2-input",
329 .name =
"span-l2-output",
359 #undef span_node_defs
sll srl srl sll sra u16x4 i
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)
static char * span_error_strings[]
struct _vlib_node_registration vlib_node_registration_t
static uword span_l2_output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
vlib_node_registration_t span_l2_output_node
(constructor) VLIB_REGISTER_NODE (span_l2_output_node)
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...
vlib_node_registration_t span_input_node
(constructor) VLIB_REGISTER_NODE (span_input_node)
clib_bitmap_t * mirror_ports
vlib_node_registration_t span_l2_input_node
(constructor) VLIB_REGISTER_NODE (span_l2_input_node)
#define static_always_inline
#define VLIB_INIT_FUNCTION(x)
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)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
clib_error_t * span_init(vlib_main_t *vm)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
static uword span_device_input_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword span_device_output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u8 * format_span_trace(u8 *s, va_list *args)
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
vlib_node_registration_t span_output_node
(constructor) VLIB_REGISTER_NODE (span_output_node)
span_interface_t * interfaces
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
vlib_node_registration_t span_node
#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.
static_always_inline void vnet_feature_next(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
#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).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
static void vnet_put_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index, vlib_frame_t *f)
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.
#define VLIB_BUFFER_IS_TRACED
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.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
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)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static uword span_l2_input_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_REGISTER_NODE(x,...)
#define foreach_span_error
#define CLIB_CACHE_LINE_BYTES
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 vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
VLIB_NODE_FUNCTION_MULTIARCH(ethernet_input_not_l2_node, ethernet_input_not_l2)