36 s =
format (s,
"SPAN: mirrored %U -> %U",
43 #define foreach_span_error \ 44 _(HITS, "SPAN incomming packets processed") 48 #define _(sym,str) SPAN_ERROR_##sym, 55 #define _(sym,string) string, 68 u32 *to_mirror_next = 0;
86 if (mirror_frames[i] == 0)
87 mirror_frames[i] = vnet_get_frame_to_sw_interface (vnm, i);
88 to_mirror_next = vlib_frame_vector_args (mirror_frames[i]);
89 to_mirror_next += mirror_frames[i]->n_vectors;
91 c0 = vlib_buffer_copy (vm, b0);
92 if (PREDICT_TRUE(c0 != 0))
94 vnet_buffer (c0)->sw_if_index[VLIB_TX] = i;
95 c0->flags |= VNET_BUFFER_SPAN_CLONE;
96 to_mirror_next[0] = vlib_get_buffer_index (vm, c0);
97 mirror_frames[i]->n_vectors++;
98 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
100 span_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
101 t->src_sw_if_index = sw_if_index0;
102 t->mirror_sw_if_index = i;
115 u32 n_left_from, *from, *to_next;
116 u32 n_span_packets = 0;
129 while (n_left_from > 0)
135 while (n_left_from >= 4 && n_left_to_next >= 2)
147 to_next[0] = bi0 = from[0];
148 to_next[1] = bi1 = from[1];
156 sw_if_index0 =
vnet_buffer (b0)->sw_if_index[rxtx];
157 sw_if_index1 =
vnet_buffer (b1)->sw_if_index[rxtx];
159 span_mirror (vm, node, sw_if_index0, b0, mirror_frames, is_rx);
160 span_mirror (vm, node, sw_if_index1, b1, mirror_frames, is_rx);
167 to_next, n_left_to_next,
168 bi0, bi1, next0, next1);
170 while (n_left_from > 0 && n_left_to_next > 0)
178 to_next[0] = bi0 = from[0];
185 sw_if_index0 =
vnet_buffer (b0)->sw_if_index[rxtx];
187 span_mirror (vm, node, sw_if_index0, b0, mirror_frames, is_rx);
193 n_left_to_next, bi0, next0);
200 for (sw_if_index = 0; sw_if_index <
vec_len (mirror_frames); sw_if_index++)
202 if (mirror_frames[sw_if_index] == 0)
206 mirror_frames[sw_if_index]);
207 mirror_frames[sw_if_index] = 0;
232 .name =
"span-input",
233 .vector_size =
sizeof (
u32),
252 .name =
"span-output",
253 .vector_size =
sizeof (
u32),
sll srl srl sll sra u16x4 i
static uword span_input_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static char * span_error_strings[]
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.
struct _vlib_node_registration vlib_node_registration_t
#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
vlib_node_registration_t span_input_node
(constructor) VLIB_REGISTER_NODE (span_input_node)
#define static_always_inline
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
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)
#define VNET_BUFFER_SPAN_CLONE
span_interface_t * interfaces
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).
clib_bitmap_t * tx_mirror_ports
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static void vnet_put_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index, vlib_frame_t *f)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static_always_inline uword span_node_inline_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_rx)
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, int is_rx)
#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.
clib_bitmap_t * rx_mirror_ports
#define VLIB_REGISTER_NODE(x,...)
static uword span_output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define foreach_span_error
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: 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)