52 #ifndef CLIB_MARCH_VARIANT 56 #define _(sym,name) name, 70 static char *display_names[] = {
71 #define _(sym,name) #sym, 75 u32 feature_bitmap = va_arg (*args,
u32);
76 u32 verbose = va_arg (*args,
u32);
78 if (feature_bitmap == 0)
80 s =
format (s,
" none configured");
84 feature_bitmap &= ~L2INPUT_FEAT_DROP;
88 if (feature_bitmap & (1 << i))
91 s =
format (s,
"%17s (%s)\n",
117 s =
format (s,
"l2-input: sw_if_index %d dst %U src %U",
126 #ifndef CLIB_MARCH_VARIANT 130 #define foreach_l2input_error \ 131 _(L2INPUT, "L2 input packets") \ 132 _(DROP, "L2 input drops") 136 #define _(sym,str) L2INPUT_ERROR_##sym, 143 #define _(sym,string) string, 189 #define get_u16(addr) ( *((u16 *)(addr)) ) 190 u16 ethertype = clib_net_to_host_u16 (
get_u16 (l3h0 - 2));
194 feat_mask &= ~(L2INPUT_FEAT_FWD |
195 L2INPUT_FEAT_UU_FLOOD |
196 L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_GBP_FWD);
198 if (ethertype != ETHERNET_TYPE_ARP)
199 feat_mask &= ~(L2INPUT_FEAT_ARP_UFWD);
202 if (ethertype != ETHERNET_TYPE_ARP &&
203 (ethertype != ETHERNET_TYPE_IP6 || protocol != IP_PROTOCOL_ICMP6))
204 feat_mask &= ~(L2INPUT_FEAT_ARP_TERM);
213 if (ethertype == ETHERNET_TYPE_ARP)
217 clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_request))
223 icmp6_neighbor_solicitation_or_advertisement_header_t *ndh0;
225 if (ndh0->icmp.type == ICMP6_neighbor_solicitation)
279 feat_mask = L2INPUT_FEAT_DROP;
285 vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap;
297 u32 n_left_from, *from, *to_next;
307 while (n_left_from > 0)
314 while (n_left_from >= 8 && n_left_to_next >= 4)
316 u32 next0, next1, next2, next3;
317 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
352 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
362 if (b[1]->
flags & VLIB_BUFFER_IS_TRACED)
372 if (b[2]->
flags & VLIB_BUFFER_IS_TRACED)
382 if (b[3]->
flags & VLIB_BUFFER_IS_TRACED)
408 to_next, n_left_to_next,
409 from[0], from[1], from[2], from[3],
410 next0, next1, next2, next3);
414 while (n_left_from > 0 && n_left_to_next > 0)
435 to_next[0] = from[0];
442 to_next, n_left_to_next,
451 L2INPUT_ERROR_L2INPUT, frame->
n_vectors);
467 .vector_size =
sizeof (
u32),
486 #ifndef CLIB_MARCH_VARIANT 552 const u8 * old_address,
const u8 * new_address)
559 if (intf_config->
bridge && intf_config->
bvi)
566 L2FIB_ENTRY_RESULT_FLAG_BVI |
567 L2FIB_ENTRY_RESULT_FLAG_STATIC);
595 i32 l2_if_adjust = 0;
695 L2INPUT_FEAT_UU_FLOOD |
696 L2INPUT_FEAT_UU_FWD |
699 L2INPUT_FEAT_ARP_UFWD |
700 L2INPUT_FEAT_ARP_TERM);
729 L2FIB_ENTRY_RESULT_FLAG_BVI |
730 L2FIB_ENTRY_RESULT_FLAG_STATIC);
756 .flags = member_flags,
773 ~(L2INPUT_FEAT_LEARN | L2INPUT_FEAT_FWD | L2INPUT_FEAT_FLOOD);
786 L2INPUT_FEAT_DROP | L2INPUT_FEAT_INPUT_CLASSIFY;
790 ~(L2INPUT_FEAT_LEARN | L2INPUT_FEAT_FWD | L2INPUT_FEAT_FLOOD);
821 else if ((hi->
l2_if_count == 0) && (l2_if_adjust == -1))
835 if (dev_class->set_l2_mode_function)
837 dev_class->set_l2_mode_function (vnet_main, hi, l2_if_adjust);
868 if (!
unformat (input,
"%d", &bd_id))
892 (void)
unformat (input,
"%d", &shg);
950 .path =
"set interface l2 bridge",
951 .short_help =
"set interface l2 bridge <interface> <bridge-domain-id> [bvi|uu-fwd] [shg]",
1016 .path =
"set interface l2 xconnect",
1017 .short_help =
"set interface l2 xconnect <interface> <peer interface>",
1066 .path =
"set interface l3",
1067 .short_help =
"set interface l3 <interface>",
1126 args =
format (0,
"bd_id %d%s%d", bd_id,
1127 config->
bvi ?
" bvi shg " :
" shg ", config->
shg);
1131 mode =
"l2 xconnect";
1182 .path =
"show mode",
1183 .short_help =
"show mode [<if-name1> <if-name2> ...]",
1188 #define foreach_l2_init_function \ 1189 _(feat_bitmap_drop_init) \ 1191 _(l2_input_classify_init) \ 1194 _(l2_in_out_acl_init) \ 1198 _(l2_efp_filter_init) \ 1205 #ifndef CLIB_MARCH_VARIANT 1212 if ((error = vlib_call_init_function (vm, a))) return error; } \ 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) ...
l2_input_config_t * configs
#define L2_FLOOD_MEMBER_NORMAL
vl_api_wireguard_peer_flags_t flags
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#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.
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
u32 bd_remove_member(l2_bridge_domain_t *bd_config, u32 sw_if_index)
#define L2_FLOOD_MEMBER_BVI
u32 * output_node_index_vec
struct _vnet_device_class vnet_device_class_t
format_function_t format_vnet_sw_if_index_name
vl_api_ip_proto_t protocol
void l2output_create_output_node_mapping(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index)
Create a mapping in the next node mapping table for the given sw_if_index.
vnet_flood_class_t flood_class
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static uword ethernet_address_cast(u8 *a)
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
#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 vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#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...)
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.
vl_api_fib_path_type_t type
l2_output_config_t * l2output_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline u8 * l2fib_valid_swif_seq_num(u32 sw_if_index)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
enum l2_bd_port_type_t_ l2_bd_port_type_t
l2output_main_t l2output_main
u32 feat_next_node_index[32]
static u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
Return the graph node index for the feature corresponding to the first set bit in the bitmap...
#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).
vl_api_tunnel_mode_t mode
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
vnet_hw_interface_class_t ethernet_hw_interface_class
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define VLIB_REGISTER_NODE(x,...)
u32 l2fib_del_entry(const u8 *mac, u32 bd_index, u32 sw_if_index)
Delete an entry from the l2fib.
#define CLIB_PREFETCH(addr, size, type)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
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.
void ethernet_register_l2_input(vlib_main_t *vm, u32 node_index)
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
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.
static void * ip6_next_header(ip6_header_t *i)
vlib_main_t vlib_node_runtime_t * node
#define VLIB_CLI_COMMAND(x,...)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void ethernet_sw_interface_set_l2_mode(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
VLIB buffer representation.
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
l2_bridge_domain_t * bd_configs
#define vec_foreach(var, vec)
Vector iterator.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
void l2fib_flush_int_mac(vlib_main_t *vm, u32 sw_if_index)
Flush all non static MACs from an interface.
vl_api_interface_index_t sw_if_index
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static uword pool_elts(void *v)
Number of active elements in a pool.