47 BVT (clib_bihash) * mac_table;
53 u32 feat_next_node_index[32];
77 s =
format (s,
"l2-fwd: sw_if_index %d dst %U src %U bd_index %d",
88 #define foreach_l2fwd_error \ 89 _(L2FWD, "L2 forward packets") \ 90 _(FLOOD, "L2 forward misses") \ 91 _(HIT, "L2 forward hits") \ 92 _(BVI_BAD_MAC, "BVI L3 MAC mismatch") \ 93 _(BVI_ETHERTYPE, "BVI packet with unhandled ethertype") \ 94 _(FILTER_DROP, "Filter Mac Drop") \ 95 _(REFLECT_DROP, "Reflection Drop") \ 96 _(STALE_DROP, "Stale entry Drop") 100 #define _(sym,str) L2FWD_ERROR_##sym, 107 #define _(sym,string) string, 129 int try_flood = result0->
raw == ~0;
134 flood_error = L2FWD_ERROR_FLOOD;
140 em->
counters[node_counter_base_index + L2FWD_ERROR_HIT] += 1;
145 int l2fib_seq_num_valid = 1;
148 if (!result0->
fields.age_not)
155 l2fib_seq_num_valid =
161 flood_error = L2FWD_ERROR_STALE_DROP;
167 b0->
error = node->
errors[L2FWD_ERROR_REFLECT_DROP];
184 &msm->l3_next, next0);
195 b0->
error = node->
errors[L2FWD_ERROR_BVI_ETHERTYPE];
209 if (
vnet_buffer (b0)->l2.feature_bitmap & L2INPUT_FEAT_UU_FLOOD)
229 u32 n_left_from, *from, *to_next;
240 cached_result.
raw = ~0;
246 while (n_left_from > 0)
253 while (n_left_from >= 8 && n_left_to_next >= 4)
255 u32 bi0, bi1, bi2, bi3;
257 u32 next0, next1, next2, next3;
258 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
262 u32 bucket0, bucket1, bucket2, bucket3;
286 to_next[0] = bi0 = from[0];
287 to_next[1] = bi1 = from[1];
288 to_next[2] = bi2 = from[2];
289 to_next[3] = bi3 = from[3];
313 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
322 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
331 if (b2->
flags & VLIB_BUFFER_IS_TRACED)
340 if (b3->
flags & VLIB_BUFFER_IS_TRACED)
353 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
376 l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0,
378 l2fwd_process (vm, node, msm, em, b1, sw_if_index1, &result1,
380 l2fwd_process (vm, node, msm, em, b2, sw_if_index2, &result2,
382 l2fwd_process (vm, node, msm, em, b3, sw_if_index3, &result3,
388 to_next, n_left_to_next,
390 next0, next1, next2, next3);
393 while (n_left_from > 0 && n_left_to_next > 0)
429 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
434 l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0,
439 to_next, n_left_to_next,
462 .vector_size =
sizeof (
u32),
492 mp->feat_next_node_index);
495 mp->mac_table = get_mac_table ();
573 .path =
"set interface l2 forward",
574 .short_help =
"set interface l2 forward <interface> [disable]",
#define TO_BVI_ERR_BAD_MAC
vnet_main_t * vnet_get_main(void)
#define TO_BVI_ERR_ETHERTYPE
static_always_inline u32 l2_to_bvi(vlib_main_t *vlib_main, vnet_main_t *vnet_main, vlib_buffer_t *b0, u32 bvi_sw_if_index, next_by_ethertype_t *l3_next, u32 *next0)
Send a packet from L2 processing to L3 via the BVI interface.
static uword l2fwd_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
clib_error_t * l2fwd_init(vlib_main_t *vm)
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
vlib_error_t * errors
Vector of errors for this node.
static vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
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...
struct l2fib_entry_result_t::@241::@243 fields
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static_always_inline void l2fwd_process(vlib_main_t *vm, vlib_node_runtime_t *node, l2fwd_main_t *msm, vlib_error_main_t *em, vlib_buffer_t *b0, u32 sw_if_index0, l2fib_entry_result_t *result0, u32 *next0)
Forward one packet based on the mac table lookup result.
static clib_error_t * int_fwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface forward enable/disable.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
vlib_error_main_t error_main
void l2fwd_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
Add the L3 input node for this ethertype to the next nodes structure.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static char * l2fwd_error_strings[]
static u8 * format_l2fwd_trace(u8 *s, va_list *args)
#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).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static_always_inline uword l2fwd_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
#define VLIB_REGISTER_NODE(x,...)
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
#define CLIB_PREFETCH(addr, size, type)
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 clib_memcpy(a, b, c)
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.
#define VLIB_CLI_COMMAND(x,...)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define foreach_l2fwd_error
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
struct _vlib_node_registration vlib_node_registration_t
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static_always_inline void l2fib_lookup_4(BVT(clib_bihash)*mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u8 *mac1, u8 *mac2, u8 *mac3, u16 bd_index0, u16 bd_index1, u16 bd_index2, u16 bd_index3, l2fib_entry_key_t *key0, l2fib_entry_key_t *key1, l2fib_entry_key_t *key2, l2fib_entry_key_t *key3, u32 *bucket0, u32 *bucket1, u32 *bucket2, u32 *bucket3, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1, l2fib_entry_result_t *result2, l2fib_entry_result_t *result3)
u16 flags
Copy of main node flags.
static_always_inline void l2fib_lookup_1(BVT(clib_bihash)*mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u16 bd_index0, l2fib_entry_key_t *key0, u32 *bucket0, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
#define VLIB_NODE_FLAG_TRACE
#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.