40 #define _(sym,name) name, 65 s =
format (s,
"l2-input: sw_if_index %d dst %U src %U",
74 #define foreach_l2input_error \ 75 _(L2INPUT, "L2 input packets") \ 76 _(DROP, "L2 input drops") 79 #define _(sym,str) L2INPUT_ERROR_##sym, 86 #define _(sym,string) string, 120 __attribute__((unused))
u8 l2bcast;
121 __attribute__((unused))
u8 l2mcast;
122 __attribute__((unused))
u8 l2_stat_kind;
134 #define get_u32(addr) ( *((u32 *)(addr)) ) 135 #define get_u16(addr) ( *((u16 *)(addr)) ) 136 #define STATS_IF_LAYER2_UCAST_INPUT_CNT 0 137 #define STATS_IF_LAYER2_MCAST_INPUT_CNT 1 138 #define STATS_IF_LAYER2_BCAST_INPUT_CNT 2 147 ethertype = clib_net_to_host_u16(
get_u16(l3h0 - 2));
148 if (ethertype == ETHERNET_TYPE_IP4) {
150 if ((protocol == IP_PROTOCOL_UDP) ||
151 (protocol == IP_PROTOCOL_TCP)) {
156 }
else if (ethertype == ETHERNET_TYPE_IP6) {
159 if ((protocol == IP_PROTOCOL_UDP) ||
160 (protocol == IP_PROTOCOL_TCP)) {
165 }
else if (ethertype == ETHERNET_TYPE_MPLS_UNICAST) {
182 feat_mask &= ~(L2INPUT_FEAT_FWD | L2INPUT_FEAT_UU_FLOOD);
183 if (ethertype != ETHERNET_TYPE_ARP)
184 feat_mask &= ~(L2INPUT_FEAT_ARP_TERM);
187 if ((*dstlo == 0xFFFFFFFF) && (*dsthi == 0xFFFFFFFF)) {
237 vnet_buffer(b0)->l2.feature_bitmap = feature_bitmap;
250 u32 n_left_from, * from, * to_next;
262 while (n_left_from > 0)
268 to_next, n_left_to_next);
270 while (n_left_from >= 6 && n_left_to_next >= 2)
275 u32 sw_if_index0, sw_if_index1;
280 u32 sw_if_index2, sw_if_index3;
309 to_next[0] = bi0 = from[0];
310 to_next[1] = bi1 = from[1];
342 em->
counters[node_counter_base_index + L2INPUT_ERROR_L2INPUT] += 2;
361 to_next, n_left_to_next,
362 bi0, bi1, next0, next1);
365 while (n_left_from > 0 && n_left_to_next > 0)
393 em->
counters[node_counter_base_index + L2INPUT_ERROR_L2INPUT] += 1;
404 to_next, n_left_to_next,
418 .vector_size =
sizeof (
u32),
493 u32 feat_mask,
u32 feat_value)
526 i32 l2_if_adjust = 0;
574 config->
feature_bitmap |= L2INPUT_FEAT_DROP | L2INPUT_FEAT_CLASSIFY;
578 ~(L2INPUT_FEAT_LEARN | L2INPUT_FEAT_FWD | L2INPUT_FEAT_FLOOD);
602 config->
feature_bitmap |= L2INPUT_FEAT_FWD | L2INPUT_FEAT_UU_FLOOD |
603 L2INPUT_FEAT_FLOOD | L2INPUT_FEAT_LEARN | L2INPUT_FEAT_ARP_TERM;
656 config->
feature_bitmap &= ~(L2INPUT_FEAT_LEARN | L2INPUT_FEAT_FWD | L2INPUT_FEAT_FLOOD);
665 out_config->
shg = shg;
678 if ((hi->
l2_if_count == 1) && (l2_if_adjust == 1)) {
688 }
else if ((hi->
l2_if_count == 0) && (l2_if_adjust == -1)) {
728 if (!
unformat (input,
"%d", &bd_id)) {
763 .path =
"set interface l2 bridge",
764 .short_help =
"set interface to L2 bridging mode in <bridge-domain ID> [bvi] [shg]",
807 .path =
"set interface l2 xconnect",
808 .short_help =
"set interface to L2 cross-connect mode with <peer interface>",
843 .path =
"set interface l3",
844 .short_help =
"set interface to L3 mode",
900 args =
format (0,
"bd_id %d%s%d", bd_id,
901 config->
bvi ?
" bvi shg " :
" shg ", config->
shg);
903 mode =
"l2 xconnect";
927 .short_help =
"show mode [<if-name1> <if-name2> ...]",
931 #define foreach_l2_init_function \ 932 _(feat_bitmap_drop_init) \ 934 _(l2_classify_init) \ 941 _(l2_efp_filter_init) \ 954 if ((error = vlib_call_init_function (vm, a))) return error; } \ void bd_validate(l2_bridge_domain_t *bd_config)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
l2_input_config_t * configs
#define L2_FLOOD_MEMBER_NORMAL
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
vnet_interface_main_t interface_main
u32 l2fib_del_entry(u64 mac, u32 bd_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
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
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_main_t * vnet_get_main(void)
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
void bd_add_member(l2_bridge_domain_t *bd_config, l2_flood_member_t *member)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline uword pool_elts(void *v)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
always_inline uword ethernet_address_cast(u8 *a)
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
l2_output_config_t * l2output_intf_config(u32 sw_if_index)
#define pool_elt_at_index(p, i)
vlib_error_main_t error_main
uword os_get_cpu_number(void)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
u32 feat_next_node_index[32]
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vnet_hw_interface_class_t ethernet_hw_interface_class
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
void ethernet_register_l2_input(vlib_main_t *vm, u32 node_index)
#define clib_memcpy(a, b, c)
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
void l2fib_add_entry(u64 mac, u32 bd_index, u32 sw_if_index, u32 static_mac, u32 filter_mac, u32 bvi_mac)
#define VLIB_CLI_COMMAND(x,...)
#define VLIB_NODE_FLAG_TRACE
#define VLIB_BUFFER_IS_TRACED
void ethernet_sw_interface_set_l2_mode(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vnet_sw_interface_t * sw_interfaces
always_inline u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
l2_bridge_domain_t * bd_configs
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
#define vec_foreach(var, vec)
Vector iterator.
#define clib_error_return(e, args...)
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
always_inline void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)