FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
l2_fib.c File Reference

Ethernet MAC Address FIB Table Management. More...

+ Include dependency graph for l2_fib.c:

Go to the source code of this file.

Data Structures

struct  l2fib_dump_walk_ctx_t_
 
struct  l2fib_show_walk_ctx_t_
 

Macros

#define vl_typedefs   /* define message structures */
 
#define vl_endianfun   /* define message structures */
 

Typedefs

typedef struct l2fib_dump_walk_ctx_t_ l2fib_dump_walk_ctx_t
 
typedef struct l2fib_show_walk_ctx_t_ l2fib_show_walk_ctx_t
 

Functions

u8format_l2fib_entry_result_flags (u8 *s, va_list *args)
 
static void incr_mac_address (u8 *mac)
 
u8format_vnet_sw_if_index_name_with_NA (u8 *s, va_list *args)
 Format sw_if_index. More...
 
static int l2fib_dump_walk_cb (BVT(clib_bihash_kv) *kvp, void *arg)
 
void l2fib_table_dump (u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
 
void l2_fib_extract_seq_num (l2fib_seq_num_t sn, u8 *bd_sn, u8 *if_sn)
 
u8format_l2_fib_seq_num (u8 *s, va_list *a)
 
static int l2fib_show_walk_cb (BVT(clib_bihash_kv) *kvp, void *arg)
 
static clib_error_tshow_l2fib (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Display the contents of the l2fib. More...
 
void l2fib_table_init (void)
 
void l2fib_clear_table (void)
 
static clib_error_tclear_l2fib (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Clear all entries in L2FIB. More...
 
static l2fib_seq_num_t l2fib_cur_seq_num (u32 bd_index, u32 sw_if_index)
 
void l2fib_add_entry (const u8 *mac, u32 bd_index, u32 sw_if_index, l2fib_entry_result_flags_t flags)
 Add an entry to the l2fib. More...
 
static clib_error_tl2fib_add (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Add an entry to the L2FIB. More...
 
static clib_error_tl2fib_test_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
u32 l2fib_del_entry (const u8 *mac, u32 bd_index, u32 sw_if_index)
 Delete an entry from the l2fib. More...
 
static clib_error_tl2fib_del (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Delete an entry from the L2FIB. More...
 
static clib_error_tl2fib_set_scan_delay (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
void l2fib_start_ager_scan (vlib_main_t *vm)
 Kick off ager to scan MACs to age/delete MAC entries. More...
 
void l2fib_flush_int_mac (vlib_main_t *vm, u32 sw_if_index)
 Flush all non static MACs from an interface. More...
 
void l2fib_flush_bd_mac (vlib_main_t *vm, u32 bd_index)
 Flush all non static MACs in a bridge domain. More...
 
void l2fib_flush_all_mac (vlib_main_t *vm)
 Flush all non static MACs - flushes all valid BDs. More...
 
static clib_error_tl2fib_flush_mac_int (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Flush MACs, except static ones, associated with an interface The CLI format is: l2fib flush-mac interface <if-name> More...
 
static clib_error_tl2fib_flush_mac_all (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Flush all MACs, except static ones The CLI format is: l2fib flush-mac all. More...
 
static clib_error_tl2fib_flush_mac_bd (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Flush bridge-domain MACs except static ones. More...
 
clib_error_tl2fib_sw_interface_up_down (vnet_main_t *vnm, u32 sw_if_index, u32 flags)
 
 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (l2fib_sw_interface_up_down)
 
 BVT (clib_bihash)
 The table of adjacencies indexed by the rewrite string. More...
 
static_always_inline void * allocate_mac_evt_buf (u32 client, u32 client_index)
 
static_always_inline f64 l2fib_scan (vlib_main_t *vm, f64 start_time, u8 event_only)
 
static uword l2fib_mac_age_scanner_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
clib_error_tl2fib_init (vlib_main_t *vm)
 
static clib_error_tlfib_config (vlib_main_t *vm, unformat_input_t *input)
 

Variables

l2fib_main_t l2fib_main
 
static vlib_cli_command_t show_l2fib_cli
 (constructor) VLIB_CLI_COMMAND (show_l2fib_cli) More...
 
static vlib_cli_command_t clear_l2fib_cli
 (constructor) VLIB_CLI_COMMAND (clear_l2fib_cli) More...
 
static vlib_cli_command_t l2fib_add_cli
 (constructor) VLIB_CLI_COMMAND (l2fib_add_cli) More...
 
static vlib_cli_command_t l2fib_test_command
 (constructor) VLIB_CLI_COMMAND (l2fib_test_command) More...
 
static vlib_cli_command_t l2fib_del_cli
 (constructor) VLIB_CLI_COMMAND (l2fib_del_cli) More...
 
static vlib_cli_command_t l2fib_set_scan_delay_cli
 (constructor) VLIB_CLI_COMMAND (l2fib_set_scan_delay_cli) More...
 
static vlib_cli_command_t l2fib_flush_mac_all_cli
 (constructor) VLIB_CLI_COMMAND (l2fib_flush_mac_all_cli) More...
 
static vlib_cli_command_t l2fib_flush_mac_int_cli
 (constructor) VLIB_CLI_COMMAND (l2fib_flush_mac_int_cli) More...
 
static vlib_cli_command_t l2fib_flush_mac_bd_cli
 (constructor) VLIB_CLI_COMMAND (l2fib_flush_mac_bd_cli) More...
 
vlib_node_registration_t l2fib_mac_age_scanner_process_node
 (constructor) VLIB_REGISTER_NODE (l2fib_mac_age_scanner_process_node) More...
 

Detailed Description

Ethernet MAC Address FIB Table Management.

The MAC Address forwarding table for bridge-domains is called the l2fib. Entries are added automatically as part of mac learning, but MAC Addresses entries can also be added manually.

Definition in file l2_fib.c.

Macro Definition Documentation

◆ vl_endianfun

#define vl_endianfun   /* define message structures */

Definition at line 40 of file l2_fib.c.

◆ vl_typedefs

#define vl_typedefs   /* define message structures */

Definition at line 36 of file l2_fib.c.

Typedef Documentation

◆ l2fib_dump_walk_ctx_t

◆ l2fib_show_walk_ctx_t

Function Documentation

◆ allocate_mac_evt_buf()

static_always_inline void* allocate_mac_evt_buf ( u32  client,
u32  client_index 
)

Definition at line 1076 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BVT()

BVT ( clib_bihash  )

The table of adjacencies indexed by the rewrite string.

Definition at line 1069 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ clear_l2fib()

static clib_error_t* clear_l2fib ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Clear all entries in L2FIB.

@TODO: Later we may want a way to remove only the non-static entries

Definition at line 405 of file l2_fib.c.

+ Here is the call graph for this function:

◆ format_l2_fib_seq_num()

u8* format_l2_fib_seq_num ( u8 s,
va_list *  a 
)

Definition at line 157 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_l2fib_entry_result_flags()

u8* format_l2fib_entry_result_flags ( u8 s,
va_list *  args 
)

Definition at line 57 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ format_vnet_sw_if_index_name_with_NA()

u8* format_vnet_sw_if_index_name_with_NA ( u8 s,
va_list *  args 
)

Format sw_if_index.

If the value is ~0, use the text "N/A"

Definition at line 90 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ incr_mac_address()

static void incr_mac_address ( u8 mac)
static

Definition at line 78 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2_fib_extract_seq_num()

void l2_fib_extract_seq_num ( l2fib_seq_num_t  sn,
u8 bd_sn,
u8 if_sn 
)

Definition at line 150 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ l2fib_add()

static clib_error_t* l2fib_add ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Add an entry to the L2FIB.

The CLI format is: l2fib add <mac> <bd> <intf> [static] [bvi] l2fib add <mac> <bd> filter Note that filter and bvi entries are always static

Definition at line 505 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_add_entry()

void l2fib_add_entry ( const u8 mac,
u32  bd_index,
u32  sw_if_index,
l2fib_entry_result_flags_t  flags 
)

Add an entry to the l2fib.

If the entry already exists then overwrite it

Definition at line 445 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_clear_table()

void l2fib_clear_table ( void  )

Definition at line 383 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_cur_seq_num()

static l2fib_seq_num_t l2fib_cur_seq_num ( u32  bd_index,
u32  sw_if_index 
)
static

Definition at line 432 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_del()

static clib_error_t* l2fib_del ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Delete an entry from the L2FIB.

The CLI format is: l2fib del <mac> <bd-id>

Definition at line 789 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_del_entry()

u32 l2fib_del_entry ( const u8 mac,
u32  bd_index,
u32  sw_if_index 
)

Delete an entry from the l2fib.

Return 0 if the entry was deleted, or 1 it was not found or if sw_if_index is non-zero and does not match that in the entry.

Definition at line 746 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_dump_walk_cb()

static int l2fib_dump_walk_cb ( BVT(clib_bihash_kv) *  kvp,
void *  arg 
)
static

Definition at line 114 of file l2_fib.c.

+ Here is the caller graph for this function:

◆ l2fib_flush_all_mac()

void l2fib_flush_all_mac ( vlib_main_t vm)

Flush all non static MACs - flushes all valid BDs.

Definition at line 926 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_flush_bd_mac()

void l2fib_flush_bd_mac ( vlib_main_t vm,
u32  bd_index 
)

Flush all non static MACs in a bridge domain.

Definition at line 915 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_flush_int_mac()

void l2fib_flush_int_mac ( vlib_main_t vm,
u32  sw_if_index 
)

Flush all non static MACs from an interface.

Definition at line 905 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_flush_mac_all()

static clib_error_t* l2fib_flush_mac_all ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Flush all MACs, except static ones The CLI format is: l2fib flush-mac all.

Definition at line 969 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_flush_mac_bd()

static clib_error_t* l2fib_flush_mac_bd ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Flush bridge-domain MACs except static ones.

The CLI format is: l2fib flush-mac bridge-domain <bd-id>

Definition at line 1014 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_flush_mac_int()

static clib_error_t* l2fib_flush_mac_int ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Flush MACs, except static ones, associated with an interface The CLI format is: l2fib flush-mac interface <if-name>

Definition at line 943 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_init()

clib_error_t* l2fib_init ( vlib_main_t vm)

Definition at line 1382 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_mac_age_scanner_process()

static uword l2fib_mac_age_scanner_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 1301 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_scan()

static_always_inline f64 l2fib_scan ( vlib_main_t vm,
f64  start_time,
u8  event_only 
)

Definition at line 1088 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_set_scan_delay()

static clib_error_t* l2fib_set_scan_delay ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 849 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_show_walk_cb()

static int l2fib_show_walk_cb ( BVT(clib_bihash_kv) *  kvp,
void *  arg 
)
static

Definition at line 183 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_start_ager_scan()

void l2fib_start_ager_scan ( vlib_main_t vm)

Kick off ager to scan MACs to age/delete MAC entries.

Definition at line 882 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_sw_interface_up_down()

clib_error_t* l2fib_sw_interface_up_down ( vnet_main_t vnm,
u32  sw_if_index,
u32  flags 
)

Definition at line 1058 of file l2_fib.c.

+ Here is the call graph for this function:

◆ l2fib_table_dump()

void l2fib_table_dump ( u32  bd_index,
l2fib_entry_key_t **  l2fe_key,
l2fib_entry_result_t **  l2fe_res 
)

Definition at line 133 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_table_init()

void l2fib_table_init ( void  )

Definition at line 369 of file l2_fib.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2fib_test_command_fn()

static clib_error_t* l2fib_test_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 610 of file l2_fib.c.

+ Here is the call graph for this function:

◆ lfib_config()

static clib_error_t* lfib_config ( vlib_main_t vm,
unformat_input_t input 
)
static

Definition at line 1410 of file l2_fib.c.

+ Here is the call graph for this function:

◆ show_l2fib()

static clib_error_t* show_l2fib ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Display the contents of the l2fib.

Definition at line 248 of file l2_fib.c.

+ Here is the call graph for this function:

◆ VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION()

VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION ( l2fib_sw_interface_up_down  )

Variable Documentation

◆ clear_l2fib_cli

vlib_cli_command_t clear_l2fib_cli
static
Initial value:
= {
.path = "clear l2fib",
.short_help = "clear l2fib",
.function = clear_l2fib,
}

(constructor) VLIB_CLI_COMMAND (clear_l2fib_cli)

Definition at line 424 of file l2_fib.c.

◆ l2fib_add_cli

vlib_cli_command_t l2fib_add_cli
static
Initial value:
= {
.path = "l2fib add",
.short_help = "l2fib add <mac> <bridge-domain-id> filter | <intf> [static | bvi]",
.function = l2fib_add,
}

(constructor) VLIB_CLI_COMMAND (l2fib_add_cli)

Definition at line 601 of file l2_fib.c.

◆ l2fib_del_cli

vlib_cli_command_t l2fib_del_cli
static
Initial value:
= {
.path = "l2fib del",
.short_help = "l2fib del <mac> <bridge-domain-id> []",
.function = l2fib_del,
}

(constructor) VLIB_CLI_COMMAND (l2fib_del_cli)

Definition at line 841 of file l2_fib.c.

◆ l2fib_flush_mac_all_cli

vlib_cli_command_t l2fib_flush_mac_all_cli
static
Initial value:
= {
.path = "l2fib flush-mac all",
.short_help = "l2fib flush-mac all",
.function = l2fib_flush_mac_all,
}

(constructor) VLIB_CLI_COMMAND (l2fib_flush_mac_all_cli)

Definition at line 985 of file l2_fib.c.

◆ l2fib_flush_mac_bd_cli

vlib_cli_command_t l2fib_flush_mac_bd_cli
static
Initial value:
= {
.path = "l2fib flush-mac bridge-domain",
.short_help = "l2fib flush-mac bridge-domain <bd-id>",
.function = l2fib_flush_mac_bd,
}

(constructor) VLIB_CLI_COMMAND (l2fib_flush_mac_bd_cli)

Definition at line 1050 of file l2_fib.c.

◆ l2fib_flush_mac_int_cli

vlib_cli_command_t l2fib_flush_mac_int_cli
static
Initial value:
= {
.path = "l2fib flush-mac interface",
.short_help = "l2fib flush-mac interface <if-name>",
.function = l2fib_flush_mac_int,
}

(constructor) VLIB_CLI_COMMAND (l2fib_flush_mac_int_cli)

Definition at line 1001 of file l2_fib.c.

◆ l2fib_mac_age_scanner_process_node

vlib_node_registration_t l2fib_mac_age_scanner_process_node
Initial value:
= {
.name = "l2fib-mac-age-scanner-process",
}

(constructor) VLIB_REGISTER_NODE (l2fib_mac_age_scanner_process_node)

Definition at line 1374 of file l2_fib.c.

◆ l2fib_main

l2fib_main_t l2fib_main

Definition at line 54 of file l2_fib.c.

◆ l2fib_set_scan_delay_cli

vlib_cli_command_t l2fib_set_scan_delay_cli
static
Initial value:
= {
.path = "set l2fib scan-delay",
.short_help = "set l2fib scan-delay <delay>",
.function = l2fib_set_scan_delay,
}

(constructor) VLIB_CLI_COMMAND (l2fib_set_scan_delay_cli)

Definition at line 872 of file l2_fib.c.

◆ l2fib_test_command

vlib_cli_command_t l2fib_test_command
static
Initial value:
= {
.path = "test l2fib",
.short_help = "test l2fib [add|del|check] mac <base-addr> count <nn>",
.function = l2fib_test_command_fn,
}

(constructor) VLIB_CLI_COMMAND (l2fib_test_command)

Definition at line 732 of file l2_fib.c.

◆ show_l2fib_cli

vlib_cli_command_t show_l2fib_cli
static
Initial value:
= {
.path = "show l2fib",
.short_help = "show l2fib [all] | [bd_id <nn> | bd_index <nn>] [learn | add] | [raw]",
.function = show_l2fib,
}

(constructor) VLIB_CLI_COMMAND (show_l2fib_cli)

Definition at line 361 of file l2_fib.c.

l2fib_del
static clib_error_t * l2fib_del(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Delete an entry from the L2FIB.
Definition: l2_fib.c:789
clear_l2fib
static clib_error_t * clear_l2fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Clear all entries in L2FIB.
Definition: l2_fib.c:405
l2fib_flush_mac_all
static clib_error_t * l2fib_flush_mac_all(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Flush all MACs, except static ones The CLI format is: l2fib flush-mac all.
Definition: l2_fib.c:969
l2fib_set_scan_delay
static clib_error_t * l2fib_set_scan_delay(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: l2_fib.c:849
l2fib_mac_age_scanner_process
static uword l2fib_mac_age_scanner_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: l2_fib.c:1301
show_l2fib
static clib_error_t * show_l2fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Display the contents of the l2fib.
Definition: l2_fib.c:248
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
l2fib_flush_mac_int
static clib_error_t * l2fib_flush_mac_int(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Flush MACs, except static ones, associated with an interface The CLI format is: l2fib flush-mac inter...
Definition: l2_fib.c:943
l2fib_flush_mac_bd
static clib_error_t * l2fib_flush_mac_bd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Flush bridge-domain MACs except static ones.
Definition: l2_fib.c:1014
l2fib_add
static clib_error_t * l2fib_add(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Add an entry to the L2FIB.
Definition: l2_fib.c:505
l2fib_test_command_fn
static clib_error_t * l2fib_test_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: l2_fib.c:610