48 BVT (clib_bihash) * mac_table;
54 u32 feat_next_node_index[32];
80 "l2-fwd: sw_if_index %d dst %U src %U bd_index %d result [0x%llx, %d] %U",
89 #ifndef CLIB_MARCH_VARIANT 97 #define foreach_l2fwd_error \ 98 _(L2FWD, "L2 forward packets") \ 99 _(FLOOD, "L2 forward misses") \ 100 _(HIT, "L2 forward hits") \ 101 _(BVI_BAD_MAC, "BVI L3 MAC mismatch") \ 102 _(BVI_ETHERTYPE, "BVI packet with unhandled ethertype") \ 103 _(FILTER_DROP, "Filter Mac Drop") \ 104 _(REFLECT_DROP, "Reflection Drop") \ 105 _(STALE_DROP, "Stale entry Drop") 109 #define _(sym,str) L2FWD_ERROR_##sym, 116 #define _(sym,string) string, 138 int try_flood = result0->
raw == ~0;
143 flood_error = L2FWD_ERROR_FLOOD;
149 em->
counters[node_counter_base_index + L2FWD_ERROR_HIT] += 1;
154 int l2fib_seq_num_valid = 1;
157 if (!l2fib_entry_result_is_set_AGE_NOT (result0))
164 l2fib_seq_num_valid =
170 flood_error = L2FWD_ERROR_STALE_DROP;
176 b0->
error = node->
errors[L2FWD_ERROR_REFLECT_DROP];
180 else if (
PREDICT_FALSE (l2fib_entry_result_is_set_FILTER (result0)))
186 else if (
PREDICT_FALSE (l2fib_entry_result_is_set_BVI (result0)))
193 &msm->l3_next, next0);
204 b0->
error = node->
errors[L2FWD_ERROR_BVI_ETHERTYPE];
219 (L2INPUT_FEAT_UU_FLOOD |
220 L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_GBP_FWD))
251 cached_result.
raw = ~0;
261 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
291 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
310 l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
311 l2fwd_process (vm, node, msm, em, b[1], sw_if_index1, &result1,
313 l2fwd_process (vm, node, msm, em, b[2], sw_if_index2, &result2,
315 l2fwd_process (vm, node, msm, em, b[3], sw_if_index3, &result3,
322 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
332 if (b[1]->
flags & VLIB_BUFFER_IS_TRACED)
342 if (b[2]->
flags & VLIB_BUFFER_IS_TRACED)
352 if (b[3]->
flags & VLIB_BUFFER_IS_TRACED)
382 em->
counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
387 l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
422 .vector_size =
sizeof (
u32),
439 #ifndef CLIB_MARCH_VARIANT 453 mp->feat_next_node_index);
456 mp->mac_table = get_mac_table ();
534 .path =
"set interface l2 forward",
535 .short_help =
"set interface l2 forward <interface> [disable]",
vl_api_wireguard_peer_flags_t flags
#define TO_BVI_ERR_BAD_MAC
vnet_main_t * vnet_get_main(void)
#define clib_memcpy_fast(a, b, c)
#define TO_BVI_ERR_ETHERTYPE
clib_error_t * l2fwd_init(vlib_main_t *vm)
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this 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...
u8 * format_l2fib_entry_result_flags(u8 *s, va_list *args)
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(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, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static clib_error_t * int_fwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface forward enable/disable.
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
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)
static_always_inline void l2fib_lookup_4(BVT(clib_bihash) *mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, const u8 *mac0, const u8 *mac1, const u8 *mac2, const 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, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1, l2fib_entry_result_t *result2, l2fib_entry_result_t *result3)
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, u16 *next0)
Forward one packet based on the mac table lookup result.
static_always_inline uword l2fwd_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
struct l2fib_entry_result_t_::@458::@460 fields
#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_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
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.
vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
vlib_main_t vlib_node_runtime_t * node
#define VLIB_CLI_COMMAND(x,...)
#define foreach_l2fwd_error
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
struct _vlib_node_registration vlib_node_registration_t
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.
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.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
vl_api_interface_index_t sw_if_index
l2fib_entry_result_t result
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, u16 *next0)
Send a packet from L2 processing to L3 via the BVI interface.