63 s =
format (s,
"l2-learn: sw_if_index %d dst %U src %U bd_index %d",
73 #define foreach_l2learn_error \ 74 _(L2LEARN, "L2 learn packets") \ 75 _(MISS, "L2 learn misses") \ 76 _(MAC_MOVE, "L2 mac moves") \ 77 _(MAC_MOVE_VIOLATE, "L2 mac move violations") \ 78 _(LIMIT, "L2 not learned due to limit") \ 79 _(HIT, "L2 learn hits") \ 80 _(FILTER_DROP, "L2 filter mac drops") 83 #define _(sym,str) L2LEARN_ERROR_##sym, 90 #define _(sym,string) string, 121 feature_bitmap =
vnet_buffer(b0)->l2.feature_bitmap & ~L2INPUT_FEAT_LEARN;
124 vnet_buffer(b0)->l2.feature_bitmap = feature_bitmap;
137 counter_base[L2LEARN_ERROR_HIT] += 1;
139 }
else if (result0->
raw == ~0) {
143 counter_base[L2LEARN_ERROR_MISS] += 1;
148 counter_base[L2LEARN_ERROR_LIMIT] += 1;
152 BVT(clib_bihash_kv) kv;
156 result0->
fields.sw_if_index = sw_if_index0;
159 kv.value = result0->
raw;
163 cached_key->
raw = ~0;
170 counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
172 if (result0->
fields.static_mac) {
175 b0->
error = node->
errors[L2LEARN_ERROR_MAC_MOVE_VIOLATE];
181 BVT(clib_bihash_kv) kv;
184 result0->
fields.sw_if_index = sw_if_index0;
187 kv.value = result0->
raw;
189 cached_key->
raw = ~0;
195 if (result0->
fields.filter) {
200 b0->
error = node->
errors[L2LEARN_ERROR_FILTER_DROP];
215 u32 n_left_from, * from, * to_next;
230 cached_result.
raw = ~0;
232 while (n_left_from > 0)
238 to_next, n_left_to_next);
240 while (n_left_from >= 4 && n_left_to_next >= 2)
245 u32 sw_if_index0, sw_if_index1;
249 u32 bucket0, bucket1;
267 to_next[0] = bi0 = from[0];
268 to_next[1] = bi1 = from[1];
309 em->
counters[node_counter_base_index + L2LEARN_ERROR_L2LEARN] += 2;
324 b0, sw_if_index0, &key0, &cached_key,
325 &bucket0, &result0, &next0);
328 b1, sw_if_index1, &key1, &cached_key,
329 &bucket1, &result1, &next1);
334 to_next, n_left_to_next,
335 bi0, bi1, next0, next1);
338 while (n_left_from > 0 && n_left_to_next > 0)
374 em->
counters[node_counter_base_index + L2LEARN_ERROR_L2LEARN] += 1;
383 b0, sw_if_index0, &key0, &cached_key,
384 &bucket0, &result0, &next0);
388 to_next, n_left_to_next,
402 .vector_size =
sizeof (
u32),
434 mp->mac_table = get_mac_table();
479 .path =
"set interface l2 learn",
480 .short_help =
"set interface l2 learn <interface> [disable]",
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
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
struct _vlib_node_registration vlib_node_registration_t
clib_error_t * l2learn_init(vlib_main_t *vm)
unformat_function_t unformat_vnet_sw_interface
int BV() clib_bihash_add_del(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*add_v, int is_add)
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)
static_always_inline void l2learn_process(vlib_node_runtime_t *node, l2learn_main_t *msm, u64 *counter_base, vlib_buffer_t *b0, u32 sw_if_index0, l2fib_entry_key_t *key0, l2fib_entry_key_t *cached_key, u32 *bucket0, l2fib_entry_result_t *result0, u32 *next0)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
static char * l2learn_error_strings[]
vlib_error_main_t error_main
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define L2FIB_NUM_BUCKETS
static u8 * format_l2learn_trace(u8 *s, va_list *args)
#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.
static vlib_node_registration_t l2learn_node
(constructor) VLIB_REGISTER_NODE (l2learn_node)
#define CLIB_PREFETCH(addr, size, type)
#define foreach_l2learn_error
static clib_error_t * l2learn_config(vlib_main_t *vm, unformat_input_t *input)
#define clib_memcpy(a, b, c)
static clib_error_t * int_learn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 feat_next_node_index[32]
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 VLIB_NODE_FLAG_TRACE
static uword l2learn_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_BUFFER_IS_TRACED
always_inline u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
l2learn_main_t l2learn_main
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.
always_inline void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)