FD.io VPP  v21.01.1
Vector Packet Processing
l2_bd.c File Reference

Ethernet Bridge Domain. More...

+ Include dependency graph for l2_bd.c:

Go to the source code of this file.

Macros

#define BD_REMOVE_ERROR_OK   0
 
#define BD_REMOVE_ERROR_NOT_FOUND   1
 

Functions

void bd_validate (l2_bridge_domain_t *bd_config)
 Init bridge domain if not done already. More...
 
u32 bd_find_index (bd_main_t *bdm, u32 bd_id)
 Get a bridge domain. More...
 
u32 bd_add_bd_index (bd_main_t *bdm, u32 bd_id)
 Create a bridge domain. More...
 
static void bd_free_ip_mac_tables (l2_bridge_domain_t *bd)
 
static int bd_delete (bd_main_t *bdm, u32 bd_index)
 
static void update_flood_count (l2_bridge_domain_t *bd_config)
 
void bd_add_member (l2_bridge_domain_t *bd_config, l2_flood_member_t *member)
 
u32 bd_remove_member (l2_bridge_domain_t *bd_config, u32 sw_if_index)
 
clib_error_tl2bd_init (vlib_main_t *vm)
 
l2_bridge_domain_tbd_get (u32 bd_index)
 
u32 bd_input_walk (u32 bd_index, bd_input_walk_fn_t fn, void *data)
 
static void b2_input_recache (u32 bd_index)
 
u32 bd_set_flags (vlib_main_t *vm, u32 bd_index, bd_flags_t flags, u32 enable)
 Set the learn/forward/flood flags for the bridge domain. More...
 
void bd_set_mac_age (vlib_main_t *vm, u32 bd_index, u8 age)
 Set the mac age for the bridge domain. More...
 
static void bd_set_bd_tag (vlib_main_t *vm, u32 bd_index, u8 *bd_tag)
 Set the tag for the bridge domain. More...
 
static clib_error_tbd_learn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain learn enable/disable. More...
 
static clib_error_tbd_fwd (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain forward enable/disable. More...
 
static clib_error_tbd_flood (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain flood enable/disable. More...
 
static clib_error_tbd_uu_flood (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain unknown-unicast flood enable/disable. More...
 
static clib_error_tbd_arp_ufwd (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain arp-unicast forward enable/disable. More...
 
static clib_error_tbd_arp_term (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain arp term enable/disable. More...
 
static clib_error_tbd_mac_age (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
u32 bd_add_del_ip_mac (u32 bd_index, ip46_type_t type, const ip46_address_t *ip, const mac_address_t *mac, u8 is_add)
 Add/delete IP address to MAC address mapping. More...
 
void bd_flush_ip_mac (u32 bd_index)
 Flush IP address to MAC address mapping tables in a BD. More...
 
static clib_error_tbd_arp_entry (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Set bridge-domain arp entry add/delete. More...
 
static u8format_uu_cfg (u8 *s, va_list *args)
 
static clib_error_tbd_show (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Show bridge-domain state. More...
 
int bd_add_del (l2_bridge_domain_add_del_args_t *a)
 
static clib_error_tbd_add_del_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 Create or delete bridge-domain. More...
 

Variables

bd_main_t bd_main
 
static vlib_cli_command_t bd_learn_cli
 (constructor) VLIB_CLI_COMMAND (bd_learn_cli) More...
 
static vlib_cli_command_t bd_fwd_cli
 (constructor) VLIB_CLI_COMMAND (bd_fwd_cli) More...
 
static vlib_cli_command_t bd_flood_cli
 (constructor) VLIB_CLI_COMMAND (bd_flood_cli) More...
 
static vlib_cli_command_t bd_uu_flood_cli
 (constructor) VLIB_CLI_COMMAND (bd_uu_flood_cli) More...
 
static vlib_cli_command_t bd_arp_ufwd_cli
 (constructor) VLIB_CLI_COMMAND (bd_arp_ufwd_cli) More...
 
static vlib_cli_command_t bd_mac_age_cli
 (constructor) VLIB_CLI_COMMAND (bd_mac_age_cli) More...
 
static vlib_cli_command_t bd_arp_term_cli
 (constructor) VLIB_CLI_COMMAND (bd_arp_term_cli) More...
 
static vlib_cli_command_t bd_arp_entry_cli
 (constructor) VLIB_CLI_COMMAND (bd_arp_entry_cli) More...
 
static vlib_cli_command_t bd_show_cli
 (constructor) VLIB_CLI_COMMAND (bd_show_cli) More...
 
static vlib_cli_command_t bd_create_cli
 (constructor) VLIB_CLI_COMMAND (bd_create_cli) More...
 

Detailed Description

Ethernet Bridge Domain.

Code in this file manages Layer 2 bridge domains.

Definition in file l2_bd.c.

Macro Definition Documentation

◆ BD_REMOVE_ERROR_NOT_FOUND

#define BD_REMOVE_ERROR_NOT_FOUND   1

Definition at line 190 of file l2_bd.c.

◆ BD_REMOVE_ERROR_OK

#define BD_REMOVE_ERROR_OK   0

Definition at line 189 of file l2_bd.c.

Function Documentation

◆ b2_input_recache()

static void b2_input_recache ( u32  bd_index)
static

Definition at line 279 of file l2_bd.c.

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

◆ bd_add_bd_index()

u32 bd_add_bd_index ( bd_main_t bdm,
u32  bd_id 
)

Create a bridge domain.

Create a bridge domain with the given bridge domain ID

Parameters
bdmbd_main pointer.
Returns
The bridge domain index in l2input_main->l2_bridge_domain_t vector.

Definition at line 79 of file l2_bd.c.

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

◆ bd_add_del()

int bd_add_del ( l2_bridge_domain_add_del_args_t a)

Definition at line 1268 of file l2_bd.c.

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

◆ bd_add_del_command_fn()

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

Create or delete bridge-domain.

The CLI format: create bridge-domain <bd_index> [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>] [mac-age <nn>] [bd-tag <tag>] [del]

Definition at line 1352 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_add_del_ip_mac()

u32 bd_add_del_ip_mac ( u32  bd_index,
ip46_type_t  type,
const ip46_address_t *  ip,
const mac_address_t mac,
u8  is_add 
)

Add/delete IP address to MAC address mapping.

The clib hash implementation stores uword entries in the hash table. The hash table mac_by_ip4 is keyed via IP4 address and store the 6-byte MAC address directly in the hash table entry uword.

Warning
This only works for 64-bit processor with 8-byte uword; which means this code WILL NOT WORK for a 32-bit processor with 4-byte uword.

Definition at line 852 of file l2_bd.c.

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

◆ bd_add_member()

void bd_add_member ( l2_bridge_domain_t bd_config,
l2_flood_member_t member 
)

Definition at line 148 of file l2_bd.c.

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

◆ bd_arp_entry()

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

Set bridge-domain arp entry add/delete.

The CLI format is: set bridge-domain arp entry <bridge-domain-id> <ip-addr> <mac-addr> [del]

Definition at line 945 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_arp_term()

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

Set bridge-domain arp term enable/disable.

The CLI format is: set bridge-domain arp term <bridge-domain-id> [disable]

Definition at line 715 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_arp_ufwd()

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

Set bridge-domain arp-unicast forward enable/disable.

The CLI format is: set bridge-domain arp-ufwd <bd_index> [disable]

Definition at line 650 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_delete()

static int bd_delete ( bd_main_t bdm,
u32  bd_index 
)
static

Definition at line 112 of file l2_bd.c.

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

◆ bd_find_index()

u32 bd_find_index ( bd_main_t bdm,
u32  bd_id 
)

Get a bridge domain.

Get a bridge domain with the given bridge domain ID.

Parameters
bdmbd_main pointer.
bd_idThe bridge domain ID
Returns
The bridge domain index in l2input_main->l2_bridge_domain_t vector.

Definition at line 70 of file l2_bd.c.

+ Here is the caller graph for this function:

◆ bd_flood()

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

Set bridge-domain flood enable/disable.

The CLI format is: set bridge-domain flood <bd_index> [disable]

Definition at line 520 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_flush_ip_mac()

void bd_flush_ip_mac ( u32  bd_index)

Flush IP address to MAC address mapping tables in a BD.

Definition at line 929 of file l2_bd.c.

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

◆ bd_free_ip_mac_tables()

static void bd_free_ip_mac_tables ( l2_bridge_domain_t bd)
inlinestatic

Definition at line 96 of file l2_bd.c.

+ Here is the caller graph for this function:

◆ bd_fwd()

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

Set bridge-domain forward enable/disable.

The CLI format is: set bridge-domain forward <bd_index> [disable]

Definition at line 455 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_get()

l2_bridge_domain_t* bd_get ( u32  bd_index)

Definition at line 247 of file l2_bd.c.

+ Here is the caller graph for this function:

◆ bd_input_walk()

u32 bd_input_walk ( u32  bd_index,
bd_input_walk_fn_t  fn,
void *  data 
)

Definition at line 255 of file l2_bd.c.

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

◆ bd_learn()

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

Set bridge-domain learn enable/disable.

The CLI format is: set bridge-domain learn <bd_id> [disable]

Definition at line 390 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_mac_age()

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

Definition at line 753 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_remove_member()

u32 bd_remove_member ( l2_bridge_domain_t bd_config,
u32  sw_if_index 
)

Definition at line 193 of file l2_bd.c.

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

◆ bd_set_bd_tag()

static void bd_set_bd_tag ( vlib_main_t vm,
u32  bd_index,
u8 bd_tag 
)
static

Set the tag for the bridge domain.

Definition at line 363 of file l2_bd.c.

+ Here is the caller graph for this function:

◆ bd_set_flags()

u32 bd_set_flags ( vlib_main_t vm,
u32  bd_index,
bd_flags_t  flags,
u32  enable 
)

Set the learn/forward/flood flags for the bridge domain.

Return 0 if ok, non-zero if for an error.

Definition at line 289 of file l2_bd.c.

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

◆ bd_set_mac_age()

void bd_set_mac_age ( vlib_main_t vm,
u32  bd_index,
u8  age 
)

Set the mac age for the bridge domain.

Definition at line 339 of file l2_bd.c.

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

◆ bd_show()

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

Show bridge-domain state.

The CLI format is: show bridge-domain [<bd_index>]

Definition at line 1057 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_uu_flood()

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

Set bridge-domain unknown-unicast flood enable/disable.

The CLI format is: set bridge-domain uu-flood <bd_index> [disable]

Definition at line 585 of file l2_bd.c.

+ Here is the call graph for this function:

◆ bd_validate()

void bd_validate ( l2_bridge_domain_t bd_config)

Init bridge domain if not done already.

For feature bitmap, set all bits except ARP termination

Definition at line 51 of file l2_bd.c.

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

◆ format_uu_cfg()

static u8* format_uu_cfg ( u8 s,
va_list *  args 
)
static

Definition at line 1038 of file l2_bd.c.

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

◆ l2bd_init()

clib_error_t* l2bd_init ( vlib_main_t vm)

Definition at line 227 of file l2_bd.c.

+ Here is the call graph for this function:

◆ update_flood_count()

static void update_flood_count ( l2_bridge_domain_t bd_config)
static

Definition at line 139 of file l2_bd.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ bd_arp_entry_cli

vlib_cli_command_t bd_arp_entry_cli
static
Initial value:
= {
.path = "set bridge-domain arp entry",
.short_help = "set bridge-domain arp entry <bridge-domain-id> [<ip-addr> <mac-addr> [del] | del-all]",
.function = bd_arp_entry,
}
static clib_error_t * bd_arp_entry(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain arp entry add/delete.
Definition: l2_bd.c:945

(constructor) VLIB_CLI_COMMAND (bd_arp_entry_cli)

Definition at line 1030 of file l2_bd.c.

◆ bd_arp_term_cli

vlib_cli_command_t bd_arp_term_cli
static
Initial value:
= {
.path = "set bridge-domain arp term",
.short_help = "set bridge-domain arp term <bridge-domain-id> [disable]",
.function = bd_arp_term,
}
static clib_error_t * bd_arp_term(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain arp term enable/disable.
Definition: l2_bd.c:715

(constructor) VLIB_CLI_COMMAND (bd_arp_term_cli)

Definition at line 832 of file l2_bd.c.

◆ bd_arp_ufwd_cli

vlib_cli_command_t bd_arp_ufwd_cli
static
Initial value:
= {
.path = "set bridge-domain arp-ufwd",
.short_help = "set bridge-domain arp-ufwd <bridge-domain-id> [disable]",
.function = bd_arp_ufwd,
}
static clib_error_t * bd_arp_ufwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain arp-unicast forward enable/disable.
Definition: l2_bd.c:650

(constructor) VLIB_CLI_COMMAND (bd_arp_ufwd_cli)

Definition at line 702 of file l2_bd.c.

◆ bd_create_cli

vlib_cli_command_t bd_create_cli
static
Initial value:
= {
.path = "create bridge-domain",
.short_help = "create bridge-domain <bridge-domain-id>"
" [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>]"
" [arp-ufwd <0|1>] [mac-age <nn>] [bd-tag <tag>] [del]",
.function = bd_add_del_command_fn,
}
static clib_error_t * bd_add_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Create or delete bridge-domain.
Definition: l2_bd.c:1352

(constructor) VLIB_CLI_COMMAND (bd_create_cli)

Definition at line 1496 of file l2_bd.c.

◆ bd_flood_cli

vlib_cli_command_t bd_flood_cli
static
Initial value:
= {
.path = "set bridge-domain flood",
.short_help = "set bridge-domain flood <bridge-domain-id> [disable]",
.function = bd_flood,
}
static clib_error_t * bd_flood(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain flood enable/disable.
Definition: l2_bd.c:520

(constructor) VLIB_CLI_COMMAND (bd_flood_cli)

Definition at line 572 of file l2_bd.c.

◆ bd_fwd_cli

vlib_cli_command_t bd_fwd_cli
static
Initial value:
= {
.path = "set bridge-domain forward",
.short_help = "set bridge-domain forward <bridge-domain-id> [disable]",
.function = bd_fwd,
}
static clib_error_t * bd_fwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain forward enable/disable.
Definition: l2_bd.c:455

(constructor) VLIB_CLI_COMMAND (bd_fwd_cli)

Definition at line 507 of file l2_bd.c.

◆ bd_learn_cli

vlib_cli_command_t bd_learn_cli
static
Initial value:
= {
.path = "set bridge-domain learn",
.short_help = "set bridge-domain learn <bridge-domain-id> [disable]",
.function = bd_learn,
}
static clib_error_t * bd_learn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain learn enable/disable.
Definition: l2_bd.c:390

(constructor) VLIB_CLI_COMMAND (bd_learn_cli)

Definition at line 442 of file l2_bd.c.

◆ bd_mac_age_cli

vlib_cli_command_t bd_mac_age_cli
static
Initial value:
= {
.path = "set bridge-domain mac-age",
.short_help = "set bridge-domain mac-age <bridge-domain-id> <mins>",
.function = bd_mac_age,
}
static clib_error_t * bd_mac_age(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: l2_bd.c:753

(constructor) VLIB_CLI_COMMAND (bd_mac_age_cli)

Definition at line 814 of file l2_bd.c.

◆ bd_main

bd_main_t bd_main

Definition at line 44 of file l2_bd.c.

◆ bd_show_cli

vlib_cli_command_t bd_show_cli
static
Initial value:
= {
.path = "show bridge-domain",
.short_help = "show bridge-domain [bridge-domain-id [detail|int|arp|bd-tag]]",
.function = bd_show,
}
static clib_error_t * bd_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Show bridge-domain state.
Definition: l2_bd.c:1057

(constructor) VLIB_CLI_COMMAND (bd_show_cli)

Definition at line 1260 of file l2_bd.c.

◆ bd_uu_flood_cli

vlib_cli_command_t bd_uu_flood_cli
static
Initial value:
= {
.path = "set bridge-domain uu-flood",
.short_help = "set bridge-domain uu-flood <bridge-domain-id> [disable]",
.function = bd_uu_flood,
}
static clib_error_t * bd_uu_flood(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set bridge-domain unknown-unicast flood enable/disable.
Definition: l2_bd.c:585

(constructor) VLIB_CLI_COMMAND (bd_uu_flood_cli)

Definition at line 637 of file l2_bd.c.