68 s =
format (s,
"l2-learn: sw_if_index %d dst %U src %U bd_index %d",
77 #define foreach_l2learn_error \ 78 _(L2LEARN, "L2 learn packets") \ 79 _(MISS, "L2 learn misses") \ 80 _(MAC_MOVE, "L2 mac moves") \ 81 _(MAC_MOVE_VIOLATE, "L2 mac move violations") \ 82 _(LIMIT, "L2 not learned due to limit") \ 83 _(HIT_UPDATE, "L2 learn hit updates") \ 84 _(FILTER_DROP, "L2 filter mac drops") 88 #define _(sym,str) L2LEARN_ERROR_##sym, 95 #define _(sym,string) string, 129 u32 dtime = timestamp - result0->
fields.timestamp;
135 if (result0->
fields.age_not)
143 if ((*count > 2) && (dtime == 1) && (dsn == 0))
146 counter_base[L2LEARN_ERROR_HIT_UPDATE] += 1;
149 else if (result0->
raw == ~0)
152 counter_base[L2LEARN_ERROR_MISS] += 1;
160 counter_base[L2LEARN_ERROR_LIMIT] += 1;
173 result0->
fields.sw_if_index = sw_if_index0;
179 if (result0->
fields.filter)
183 b0->
error = node->
errors[L2LEARN_ERROR_FILTER_DROP];
188 if (result0->
fields.static_mac)
194 b0->
error = node->
errors[L2LEARN_ERROR_MAC_MOVE_VIOLATE];
203 result0->
fields.sw_if_index = sw_if_index0;
204 if (result0->
fields.age_not)
207 result0->
fields.age_not = 0;
211 counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
215 result0->
fields.timestamp = timestamp;
218 BVT (clib_bihash_kv) kv;
220 kv.value = result0->
raw;
224 cached_key->
raw = ~0;
232 u32 n_left_from, *from, *to_next;
249 cached_result.
raw = ~0;
251 while (n_left_from > 0)
258 while (n_left_from >= 8 && n_left_to_next >= 4)
260 u32 bi0, bi1, bi2, bi3;
262 u32 next0, next1, next2, next3;
263 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
267 u32 bucket0, bucket1, bucket2, bucket3;
291 to_next[0] = bi0 = from[0];
292 to_next[1] = bi1 = from[1];
293 to_next[2] = bi2 = from[2];
294 to_next[3] = bi3 = from[3];
320 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
329 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
338 if (b2->
flags & VLIB_BUFFER_IS_TRACED)
347 if (b3->
flags & VLIB_BUFFER_IS_TRACED)
360 L2LEARN_ERROR_L2LEARN, 4);
371 &key0, &key1, &key2, &key3,
372 &bucket0, &bucket1, &bucket2, &bucket3,
373 &result0, &result1, &result2, &result3);
376 b0, sw_if_index0, &key0, &cached_key,
377 &count, &result0, &next0, timestamp);
380 b1, sw_if_index1, &key1, &cached_key,
381 &count, &result1, &next1, timestamp);
384 b2, sw_if_index2, &key2, &cached_key,
385 &count, &result2, &next2, timestamp);
388 b3, sw_if_index3, &key3, &cached_key,
389 &count, &result3, &next3, timestamp);
394 to_next, n_left_to_next,
396 next0, next1, next2, next3);
399 while (n_left_from > 0 && n_left_to_next > 0)
435 L2LEARN_ERROR_L2LEARN, 1);
440 &key0, &bucket0, &result0);
443 b0, sw_if_index0, &key0, &cached_key,
444 &count, &result0, &next0, timestamp);
448 to_next, n_left_to_next,
471 .vector_size =
sizeof (
u32),
504 mp->mac_table = get_mac_table ();
565 .path =
"set interface l2 learn",
566 .short_help =
"set interface l2 learn <interface> [disable]",
vnet_main_t * vnet_get_main(void)
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.
clib_error_t * l2learn_init(vlib_main_t *vm)
unformat_function_t unformat_vnet_sw_interface
vlib_error_t * errors
Vector of errors for this 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
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 *count, l2fib_entry_result_t *result0, u32 *next0, u8 timestamp)
Perform learning on one packet based on the mac table lookup result.
l2learn_main_t l2learn_main
#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)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static char * l2learn_error_strings[]
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
vlib_error_main_t error_main
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define VLIB_CONFIG_FUNCTION(x, n,...)
static_always_inline uword l2learn_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
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 VLIB_REGISTER_NODE(x,...)
#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]
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.
struct l2fib_entry_key_t::@233::@235 fields
static uword l2learn_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
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.
static vlib_node_registration_t l2learn_node
(constructor) VLIB_REGISTER_NODE (l2learn_node)
#define L2LEARN_DEFAULT_LIMIT