56 ~(L2INPUT_FEAT_ARP_TERM | L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_ARP_UFWD);
105 clib_mem_free (ip6_addr_key);
189 #define BD_REMOVE_ERROR_OK 0 190 #define BD_REMOVE_ERROR_NOT_FOUND 1 257 u32 feature_bitmap = 0;
261 feature_bitmap |= L2INPUT_FEAT_LEARN;
265 feature_bitmap |= L2INPUT_FEAT_FWD;
269 feature_bitmap |= L2INPUT_FEAT_FLOOD;
273 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
277 feature_bitmap |= L2INPUT_FEAT_ARP_TERM;
281 feature_bitmap |= L2INPUT_FEAT_ARP_UFWD;
311 enable |= bd_config->
bd_id != ~0 && bd_config->
mac_age != 0;
359 if (!
unformat (input,
"%d", &bd_id))
368 "No operations on the default bridge domain are supported");
403 .path =
"set bridge-domain learn",
404 .short_help =
"set bridge-domain learn <bridge-domain-id> [disable]",
423 if (!
unformat (input,
"%d", &bd_id))
432 "No operations on the default bridge domain are supported");
468 .path =
"set bridge-domain forward",
469 .short_help =
"set bridge-domain forward <bridge-domain-id> [disable]",
489 if (!
unformat (input,
"%d", &bd_id))
498 "No operations on the default bridge domain are supported");
533 .path =
"set bridge-domain flood",
534 .short_help =
"set bridge-domain flood <bridge-domain-id> [disable]",
554 if (!
unformat (input,
"%d", &bd_id))
563 "No operations on the default bridge domain are supported");
598 .path =
"set bridge-domain uu-flood",
599 .short_help =
"set bridge-domain uu-flood <bridge-domain-id> [disable]",
619 if (!
unformat (input,
"%d", &bd_id))
628 "No operations on the default bridge domain are supported");
663 .path =
"set bridge-domain arp-ufwd",
664 .short_help =
"set bridge-domain arp-ufwd <bridge-domain-id> [disable]",
684 if (!
unformat (input,
"%d", &bd_id))
693 "No operations on the default bridge domain are supported");
722 if (!
unformat (input,
"%d", &bd_id))
731 "No operations on the default bridge domain are supported");
775 .path =
"set bridge-domain mac-age",
776 .short_help =
"set bridge-domain mac-age <bridge-domain-id> <mins>",
793 .path =
"set bridge-domain arp term",
794 .short_help =
"set bridge-domain arp term <bridge-domain-id> [disable]",
814 const ip46_address_t *
ip,
838 else if (*old_mac == new_mac)
853 if (old_mac && (*old_mac == new_mac))
869 if (old_mac && (*old_mac == new_mac))
876 if (old_mac && (*old_mac == new_mac))
917 if (!
unformat (input,
"%d", &bd_id))
926 "No operations on the default bridge domain are supported");
943 else if (
unformat (input,
"del-all"))
971 is_add ?
"add" :
"del",
991 .path =
"set bridge-domain arp entry",
992 .short_help =
"set bridge-domain arp entry <bridge-domain-id> [<ip-addr> <mac-addr> [del] | del-all]",
1000 u32 vtr_op = va_arg (*args,
u32);
1001 u32 dot1q = va_arg (*args,
u32);
1002 u32 tag1 = va_arg (*args,
u32);
1003 u32 tag2 = va_arg (*args,
u32);
1007 return format (s,
"none");
1009 return format (s,
"push-1 %s %d", dot1q ?
"dot1q" :
"dot1ad", tag1);
1011 return format (s,
"push-2 %s %d %d", dot1q ?
"dot1q" :
"dot1ad", tag1,
1014 return format (s,
"pop-1");
1016 return format (s,
"pop-2");
1018 return format (s,
"trans-1-1 %s %d", dot1q ?
"dot1q" :
"dot1ad", tag1);
1020 return format (s,
"trans-1-2 %s %d %d", dot1q ?
"dot1q" :
"dot1ad",
1023 return format (s,
"trans-2-1 %s %d", dot1q ?
"dot1q" :
"dot1ad", tag1);
1025 return format (s,
"trans-2-2 %s %d %d", dot1q ?
"dot1q" :
"dot1ad",
1028 return format (s,
"none");
1041 return (
format (s,
"flood"));
1043 return (
format (s,
"drop"));
1070 if (
unformat (input,
"%d", &bd_id))
1085 "No operations on the default bridge domain are supported");
1110 for (bd_index = start; bd_index < end; bd_index++)
1119 "%=8s %=7s %=4s %=9s %=9s %=9s %=11s %=9s %=9s %=9s %=11s",
1120 "BD-ID",
"Index",
"BSN",
"Age(min)",
1121 "Learning",
"U-Forwrd",
"UU-Flood",
1122 "Flooding",
"ARP-Term",
"arp-ufwd",
1131 "%=8d %=7d %=4d %=9v %=9s %=9s %=11U %=9s %=9s %=9s %=11U",
1157 u32 vtr_opr, dot1q, tag1, tag2;
1161 "Interface",
"If-idx",
"ISN",
"SHG",
1162 "BVI",
"TxFlood",
"VLAN-Tag-Rewrite");
1169 swif_seq_num, member->
shg,
1171 "-", i < bd_config->flood_count ?
"*" :
"-",
1179 0, 0,
"uu",
"-",
"None");
1183 if ((detail || arp) &&
1190 "\n IP4/IP6 to MAC table for ARP Termination");
1195 vlib_cli_output (vm,
"%=40U => %=20U",
1196 format_ip4_address, &ip4_addr,
1197 format_ethernet_address, &mac_addr);
1202 vlib_cli_output (vm,
"%=40U => %=20U",
1203 format_ip6_address, ip6_addr,
1204 format_ethernet_address, &mac_addr);
1209 if ((detail || bd_tag) && (bd_config->
bd_tag))
1254 .path =
"show bridge-domain",
1255 .short_help =
"show bridge-domain [bridge-domain-id [detail|int|arp|bd-tag]]",
1271 return VNET_API_ERROR_BD_ALREADY_EXISTS;
1273 return VNET_API_ERROR_BD_ID_EXCEED_MAX;
1276 bd_flags_t enable_flags = 0, disable_flags = 0;
1322 return VNET_API_ERROR_NO_SUCH_ENTRY;
1324 return VNET_API_ERROR_BD_NOT_MODIFIABLE;
1326 return VNET_API_ERROR_BD_IN_USE;
1348 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term =
1361 if (
unformat (line_input,
"%d", &bd_id))
1363 else if (
unformat (line_input,
"flood %d", &flood))
1365 else if (
unformat (line_input,
"uu-flood %d", &uu_flood))
1367 else if (
unformat (line_input,
"forward %d", &forward))
1369 else if (
unformat (line_input,
"learn %d", &learn))
1371 else if (
unformat (line_input,
"arp-term %d", &arp_term))
1373 else if (
unformat (line_input,
"arp-ufwd %d", &arp_ufwd))
1375 else if (
unformat (line_input,
"mac-age %d", &mac_age))
1377 else if (
unformat (line_input,
"bd-tag %s", &bd_tag))
1379 else if (
unformat (line_input,
"del"))
1382 flood = uu_flood = forward = learn = 0;
1405 if ((bd_tag) && (strlen ((
char *) bd_tag) > 63))
1431 case VNET_API_ERROR_BD_IN_USE:
1434 case VNET_API_ERROR_NO_SUCH_ENTRY:
1437 case VNET_API_ERROR_BD_NOT_MODIFIABLE:
1440 case VNET_API_ERROR_BD_ID_EXCEED_MAX:
1486 .path =
"create bridge-domain",
1487 .short_help =
"create bridge-domain <bridge-domain-id>" 1488 " [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>]" 1489 " [arp-ufwd <0|1>] [mac-age <nn>] [bd-tag <tag>] [del]",
void bd_validate(l2_bridge_domain_t *bd_config)
Init bridge domain if not done already.
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
u8 * format_vnet_sw_if_index_name_with_NA(u8 *s, va_list *args)
Format sw_if_index.
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.
#define hash_unset(h, key)
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.
vnet_main_t * vnet_get_main(void)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void update_flood_count(l2_bridge_domain_t *bd_config)
l2_flood_member_t * members
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
#define hash_set_mem(h, key, value)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
int bd_add_del(l2_bridge_domain_add_del_args_t *a)
u32 bd_remove_member(l2_bridge_domain_t *bd_config, u32 sw_if_index)
#define L2_FLOOD_MEMBER_BVI
format_function_t format_vnet_sw_if_index_name
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define clib_memcpy(d, s, n)
vnet_flood_class_t flood_class
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
void bd_add_member(l2_bridge_domain_t *bd_config, l2_flood_member_t *member)
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.
#define hash_foreach(key_var, value_var, h, body)
clib_error_t * l2bd_init(vlib_main_t *vm)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define hash_get_pair(h, key)
static u8 * format_vtr(u8 *s, va_list *args)
static void bd_set_bd_tag(vlib_main_t *vm, u32 bd_index, u8 *bd_tag)
Set the tag for the bridge domain.
uword * bd_index_by_bd_id
vl_api_fib_path_type_t type
#define BD_REMOVE_ERROR_OK
#define hash_create_mem(elts, key_bytes, value_bytes)
#define hash_unset_mem(h, key)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
void l2fib_flush_bd_mac(vlib_main_t *vm, u32 bd_index)
Flush all non static MACs in a bridge domain.
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.
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.
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.
#define hash_foreach_mem(key_var, value_var, h, body)
static u8 * format_uu_cfg(u8 *s, va_list *args)
static u32 bd_is_valid(l2_bridge_domain_t *bd_config)
uword unformat_mac_address_t(unformat_input_t *input, va_list *args)
#define BD_REMOVE_ERROR_NOT_FOUND
#define ip46_address_initializer
static int bd_delete(bd_main_t *bdm, u32 bd_index)
void bd_set_mac_age(vlib_main_t *vm, u32 bd_index, u8 age)
Set the mac age for the bridge domain.
#define vec_free(V)
Free vector's memory (no header).
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.
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.
static void bd_free_ip_mac_tables(l2_bridge_domain_t *bd)
void bd_flush_ip_mac(u32 bd_index)
Flush IP address to MAC address mapping tables in a BD.
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * bd_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Show bridge-domain state.
#define hash_create(elts, value_bytes)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
#define vec_insert_elts(V, E, N, M)
Insert N vector elements starting at element M, insert given elements (no header, unspecified alignme...
static void clib_mem_free(void *p)
static void * clib_mem_alloc(uword size)
static vlib_main_t * vlib_get_main(void)
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.
static clib_error_t * bd_mac_age(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static_always_inline u64 mac_address_as_u64(const mac_address_t *mac)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
l2_bridge_domain_t * bd_configs
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.
#define hash_get_mem(h, key)
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
u8 * format_mac_address_t(u8 *s, va_list *args)
#define vec_foreach(var, vec)
Vector iterator.
u32 bd_find_index(bd_main_t *bdm, u32 bd_id)
Get a bridge domain.
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
vlib_node_registration_t l2fib_mac_age_scanner_process_node
(constructor) VLIB_REGISTER_NODE (l2fib_mac_age_scanner_process_node)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u32 bd_add_bd_index(bd_main_t *bdm, u32 bd_id)
Create a bridge domain.
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
enum bd_flags_t_ bd_flags_t