66 s =
format (s,
"l2-learn: sw_if_index %d dst %U src %U bd_index %d",
75 #define foreach_l2learn_error \ 76 _(L2LEARN, "L2 learn packets") \ 77 _(MISS, "L2 learn misses") \ 78 _(MAC_MOVE, "L2 mac moves") \ 79 _(MAC_MOVE_VIOLATE, "L2 mac move violations") \ 80 _(LIMIT, "L2 not learned due to limit") \ 81 _(HIT, "L2 learn hits") \ 82 _(FILTER_DROP, "L2 filter mac drops") 86 #define _(sym,str) L2LEARN_ERROR_##sym, 93 #define _(sym,string) string, 124 feature_bitmap =
vnet_buffer (b0)->l2.feature_bitmap & ~L2INPUT_FEAT_LEARN;
127 vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap;
140 counter_base[L2LEARN_ERROR_HIT] += 1;
142 result0->
fields.timestamp = timestamp;
145 else if (result0->
raw == ~0)
150 counter_base[L2LEARN_ERROR_MISS] += 1;
158 counter_base[L2LEARN_ERROR_LIMIT] += 1;
164 BVT (clib_bihash_kv) kv;
168 result0->
fields.sw_if_index = sw_if_index0;
169 result0->
fields.timestamp = timestamp;
171 kv.value = result0->
raw;
175 cached_key->
raw = ~0;
184 counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
186 if (result0->
fields.static_mac)
192 b0->
error = node->
errors[L2LEARN_ERROR_MAC_MOVE_VIOLATE];
202 BVT (clib_bihash_kv) kv;
205 result0->
fields.sw_if_index = sw_if_index0;
206 result0->
fields.timestamp = timestamp;
209 kv.value = result0->
raw;
211 cached_key->
raw = ~0;
217 if (result0->
fields.filter)
224 b0->
error = node->
errors[L2LEARN_ERROR_FILTER_DROP];
238 u32 n_left_from, *from, *to_next;
254 cached_result.
raw = ~0;
256 while (n_left_from > 0)
263 while (n_left_from >= 8 && n_left_to_next >= 4)
265 u32 bi0, bi1, bi2, bi3;
267 u32 next0, next1, next2, next3;
268 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
272 u32 bucket0, bucket1, bucket2, bucket3;
296 to_next[0] = bi0 = from[0];
297 to_next[1] = bi1 = from[1];
298 to_next[2] = bi2 = from[2];
299 to_next[3] = bi3 = from[3];
365 L2LEARN_ERROR_L2LEARN, 4);
376 &key0, &key1, &key2, &key3,
377 &bucket0, &bucket1, &bucket2, &bucket3,
378 &result0, &result1, &result2, &result3);
381 b0, sw_if_index0, &key0, &cached_key,
382 &bucket0, &result0, &next0, timestamp);
385 b1, sw_if_index1, &key1, &cached_key,
386 &bucket1, &result1, &next1, timestamp);
389 b2, sw_if_index2, &key2, &cached_key,
390 &bucket2, &result2, &next2, timestamp);
393 b3, sw_if_index3, &key3, &cached_key,
394 &bucket3, &result3, &next3, timestamp);
399 to_next, n_left_to_next,
401 next0, next1, next2, next3);
404 while (n_left_from > 0 && n_left_to_next > 0)
441 L2LEARN_ERROR_L2LEARN, 1);
446 &key0, &bucket0, &result0);
449 b0, sw_if_index0, &key0, &cached_key,
450 &bucket0, &result0, &next0, timestamp);
454 to_next, n_left_to_next,
469 .vector_size =
sizeof (
u32),
502 mp->mac_table = get_mac_table ();
563 .path =
"set interface l2 learn",
564 .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)
Release pointer to next frame vector data.
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, u8 timestamp)
Perform learning on one packet based on the mac table lookup result.
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static f64 vlib_time_now(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.
struct _vlib_node_registration vlib_node_registration_t
clib_error_t * l2learn_init(vlib_main_t *vm)
unformat_function_t unformat_vnet_sw_interface
vnet_main_t * vnet_get_main(void)
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
int clib_bihash_add_del(clib_bihash *h, clib_bihash_kv *add_v, int is_add)
Add or delete a (key,value) pair from a bi-hash table.
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static char * l2learn_error_strings[]
vlib_error_main_t error_main
struct l2fib_entry_result_t::@193::@195 fields
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define L2FIB_NUM_BUCKETS
static u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
Return the graph node index for the feature corresponding to the first set bit in the bitmap...
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)
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 void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#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 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)
Set subinterface learn enable/disable.
u32 feat_next_node_index[32]
#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
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
l2learn_main_t l2learn_main
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)
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 clib_error_return(e, args...)
#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.
static vlib_node_registration_t l2learn_node
(constructor) VLIB_REGISTER_NODE (l2learn_node)