37 BVT(clib_bihash) *mac_table;
62 s =
format (s,
"l2-fwd: sw_if_index %d dst %U src %U bd_index %d",
74 #define foreach_l2fwd_error \ 75 _(L2FWD, "L2 forward packets") \ 76 _(FLOOD, "L2 forward misses") \ 77 _(HIT, "L2 forward hits") \ 78 _(BVI_BAD_MAC, "BVI L3 MAC mismatch") \ 79 _(BVI_ETHERTYPE, "BVI packet with unhandled ethertype") \ 80 _(FILTER_DROP, "Filter Mac Drop") \ 81 _(REFLECT_DROP, "Reflection Drop") 84 #define _(sym,str) L2FWD_ERROR_##sym, 91 #define _(sym,string) string, 119 if (
vnet_buffer(b0)->l2.feature_bitmap & L2INPUT_FEAT_UU_FLOOD) {
131 em->
counters[node_counter_base_index + L2FWD_ERROR_HIT] += 1;
139 b0->
error = node->
errors[L2FWD_ERROR_REFLECT_DROP];
162 b0->
error = node->
errors[L2FWD_ERROR_BVI_ETHERTYPE];
176 u32 n_left_from, * from, * to_next;
187 cached_result.
raw = ~0;
193 while (n_left_from > 0)
199 to_next, n_left_to_next);
201 while (n_left_from >= 4 && n_left_to_next >= 2)
206 u32 sw_if_index0, sw_if_index1;
210 u32 bucket0, bucket1;
228 to_next[0] = bi0 = from[0];
229 to_next[1] = bi1 = from[1];
269 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 2;
282 l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0, &next0);
283 l2fwd_process (vm, node, msm, em, b1, sw_if_index1, &result1, &next1);
288 to_next, n_left_to_next,
289 bi0, bi1, next0, next1);
292 while (n_left_from > 0 && n_left_to_next > 0)
329 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
336 l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0, &next0);
340 to_next, n_left_to_next,
353 .vector_size =
sizeof (
u32),
378 mp->mac_table = get_mac_table();
443 .path =
"set interface l2 forward",
444 .short_help =
"set interface l2 forward <interface> [disable]",
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
#define TO_BVI_ERR_BAD_MAC
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#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)
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)
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_main_t * vnet_get_main(void)
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
int vlib_main(vlib_main_t *vm, unformat_input_t *input)
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)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
static clib_error_t * int_fwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_error_main_t error_main
void l2fwd_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
static char * l2fwd_error_strings[]
static u8 * format_l2fwd_trace(u8 *s, va_list *args)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
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 vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
#define clib_memcpy(a, b, c)
static_always_inline void l2fib_lookup_2(BVT(clib_bihash)*mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u8 *mac1, u16 bd_index0, u16 bd_index1, l2fib_entry_key_t *key0, l2fib_entry_key_t *key1, u32 *bucket0, u32 *bucket1, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1)
struct l2fib_entry_result_t::@128::@130 fields
#define VLIB_CLI_COMMAND(x,...)
#define foreach_l2fwd_error
#define VLIB_NODE_FLAG_TRACE
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define VLIB_BUFFER_IS_TRACED
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
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)
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.