47 #define foreach_ethernet_input_next \ 48 _ (PUNT, "error-punt") \ 49 _ (DROP, "error-drop") \ 53 #define _(s,n) ETHERNET_INPUT_NEXT_##s, 105 *type = clib_net_to_host_u16(e0->
type);
114 *type = clib_net_to_host_u16(e0[0]);
128 if ((*type == ETHERNET_TYPE_VLAN) ||
129 (*type == ETHERNET_TYPE_DOT1AD) ||
130 (*type == ETHERNET_TYPE_VLAN_9100) ||
131 (*type == ETHERNET_TYPE_VLAN_9200))
142 *outer_id = tag & 0xfff;
144 *type = clib_net_to_host_u16(h0->
type);
149 if (*type == ETHERNET_TYPE_VLAN) {
157 *inner_id = tag & 0xfff;
159 *type = clib_net_to_host_u16(h0->
type);
164 if (*type == ETHERNET_TYPE_VLAN) {
184 u32 * new_sw_if_index,
191 main_intf, vlan_intf, qinq_intf,
192 new_sw_if_index, error0, is_l2);
201 e0 = (
void *) (b0->
data +
vnet_buffer (b0)->ethernet.start_of_ethernet_header);
205 *error0 = ETHERNET_ERROR_L3_MAC_MISMATCH;
211 *error0 = (*new_sw_if_index) != ~0 ? (*error0) : ETHERNET_ERROR_DOWN;
226 *next0 = ETHERNET_INPUT_NEXT_DROP;
234 }
else if (type0 == ETHERNET_TYPE_IP4) {
236 }
else if (type0 == ETHERNET_TYPE_IP6) {
238 }
else if (type0 == ETHERNET_TYPE_MPLS_UNICAST) {
256 *next0 = ETHERNET_INPUT_NEXT_LLC;
270 u32 n_left_from, next_index, * from, * to_next;
271 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
291 stats_n_packets = stats_n_bytes = 0;
293 while (n_left_from > 0)
299 while (n_left_from >= 4 && n_left_to_next >= 2)
303 u8 next0, next1, error0, error1;
304 u16 type0, orig_type0, type1, orig_type1;
305 u16 outer_id0, inner_id0, outer_id1, inner_id1;
306 u32 match_flags0, match_flags1;
307 u32 old_sw_if_index0, new_sw_if_index0, len0, old_sw_if_index1, new_sw_if_index1, len1;
340 error0 = error1 = ETHERNET_ERROR_NONE;
404 vnet_buffer (b0)->sw_if_index[
VLIB_RX] = error0 != ETHERNET_ERROR_NONE ? old_sw_if_index0 : new_sw_if_index0;
405 vnet_buffer (b1)->sw_if_index[
VLIB_RX] = error1 != ETHERNET_ERROR_NONE ? old_sw_if_index1 : new_sw_if_index1;
408 if (((new_sw_if_index0 != ~0) && (new_sw_if_index0 != old_sw_if_index0)) ||
409 ((new_sw_if_index1 != ~0) && (new_sw_if_index1 != old_sw_if_index1))) {
412 -
vnet_buffer (b0)->ethernet.start_of_ethernet_header;
414 -
vnet_buffer (b1)->ethernet.start_of_ethernet_header;
416 stats_n_packets += 2;
417 stats_n_bytes += len0 + len1;
419 if (
PREDICT_FALSE (! (new_sw_if_index0 == stats_sw_if_index && new_sw_if_index1 == stats_sw_if_index)))
421 stats_n_packets -= 2;
422 stats_n_bytes -= len0 + len1;
424 if (new_sw_if_index0 != old_sw_if_index0 && new_sw_if_index0 != ~0)
432 if (new_sw_if_index1 != old_sw_if_index1 && new_sw_if_index1 != ~0)
441 if (new_sw_if_index0 == new_sw_if_index1)
443 if (stats_n_packets > 0)
452 stats_n_packets = stats_n_bytes = 0;
454 stats_sw_if_index = new_sw_if_index0;
472 while (n_left_from > 0 && n_left_to_next > 0)
477 u16 type0, orig_type0;
478 u16 outer_id0, inner_id0;
480 u32 old_sw_if_index0, new_sw_if_index0, len0;
488 if (n_left_from > 1) {
505 error0 = ETHERNET_ERROR_NONE;
539 vnet_buffer (b0)->sw_if_index[
VLIB_RX] = error0 != ETHERNET_ERROR_NONE ? old_sw_if_index0 : new_sw_if_index0;
550 if ((new_sw_if_index0 != ~0) && (new_sw_if_index0 != old_sw_if_index0)) {
553 -
vnet_buffer (b0)->ethernet.start_of_ethernet_header;
555 stats_n_packets += 1;
556 stats_n_bytes += len0;
561 stats_n_packets -= 1;
562 stats_n_bytes -= len0;
564 if (new_sw_if_index0 != ~0)
572 if (stats_n_packets > 0) {
580 stats_n_packets = stats_n_bytes = 0;
582 stats_sw_if_index = new_sw_if_index0;
595 to_next, n_left_to_next,
603 if (stats_n_packets > 0)
914 #define ethernet_error(n,c,s) s, 916 #undef ethernet_error 921 .name =
"ethernet-input",
923 .vector_size =
sizeof (
u32),
930 #define _(s,n) [ETHERNET_INPUT_NEXT_##s] = n, 942 .name =
"ethernet-input-type",
944 .vector_size =
sizeof (
u32),
948 #define _(s,n) [ETHERNET_INPUT_NEXT_##s] = n, 956 .name =
"ethernet-input-not-l2",
958 .vector_size =
sizeof (
u32),
962 #define _(s,n) [ETHERNET_INPUT_NEXT_##s] = n, 1038 if (ethertype == ETHERNET_TYPE_IP4) {
1040 }
else if (ethertype == ETHERNET_TYPE_IP6) {
1042 }
else if (ethertype == ETHERNET_TYPE_MPLS_UNICAST) {
1053 __attribute__((unused))
vlan_table_t * invalid_vlan_table;
1054 __attribute__((unused))
qinq_table_t * invalid_qinq_table;
struct vnet_sub_interface_t::@91 eth
always_inline u32 eth_mac_equal(u8 *mac1, u8 *mac2)
#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)
static clib_error_t * ethernet_input_init(vlib_main_t *vm)
sll srl srl sll sra u16x4 i
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ethernet_sw_interface_add_del)
always_inline ethernet_type_info_t * ethernet_get_type_info(ethernet_main_t *em, ethernet_type_t type)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
vnet_interface_main_t interface_main
int vnet_hw_interface_rx_redirect_to_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
always_inline void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
#define SUBINT_CONFIG_MATCH_0_TAG
#define ethernet_buffer_header_size(b)
Determine the size of the Ethernet headers of the current frame in the buffer.
struct _vlib_node_registration vlib_node_registration_t
void ethernet_sw_interface_set_l2_mode_noport(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
vlib_node_registration_t ethernet_input_not_l2_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_not_l2_node)
subint_config_t inner_any_subint
#define clib_error_report(e)
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
static subint_config_t * ethernet_sw_interface_get_config(vnet_main_t *vnm, u32 sw_if_index, u32 *flags, u32 *unsupported)
ethernet_main_t ethernet_main
vnet_main_t * vnet_get_main(void)
static uword ethernet_input_not_l2(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define static_always_inline
static_always_inline uword ethernet_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, ethernet_input_variant_t variant)
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
always_inline void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
#define sparse_vec_validate(v, i)
subint_config_t default_subint
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define vlib_call_init_function(vm, x)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
always_inline uword ethernet_address_cast(u8 *a)
static u8 * format_ethernet_input_trace(u8 *s, va_list *va)
subint_config_t single_tag_subint
u32 * sparse_index_by_input_next_index
uword os_get_cpu_number(void)
always_inline void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
void ethernet_sw_interface_set_l2_mode(vnet_main_t *vnm, u32 sw_if_index, u32 l2)
#define ethernet_buffer_set_vlan_count(b, v)
Sets the number of VLAN headers in the current Ethernet frame in the buffer.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
void ethernet_register_l3_redirect(vlib_main_t *vm, u32 node_index)
#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)
#define SUBINT_CONFIG_MATCH_3_TAG
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static clib_error_t * ethernet_init(vlib_main_t *vm)
vnet_hw_interface_class_t ethernet_hw_interface_class
u8 next_by_ethertype_register_called
subint_config_t untagged_subint
#define foreach_ethernet_input_next
void ethernet_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
static uword ethernet_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define SUBINT_CONFIG_VALID
qinq_intf_t vlans[ETHERNET_N_VLAN]
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void determine_next_node(ethernet_main_t *em, ethernet_input_variant_t variant, u32 is_l20, u32 type0, vlib_buffer_t *b0, u8 *error0, u8 *next0)
clib_error_t * ethernet_sw_interface_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
always_inline void eth_vlan_table_lookups(ethernet_main_t *em, vnet_main_t *vnm, u32 port_sw_if_index0, u16 first_ethertype, u16 outer_id, u16 inner_id, vnet_hw_interface_t **hi, main_intf_t **main_intf, vlan_intf_t **vlan_intf, qinq_intf_t **qinq_intf)
#define SUBINT_CONFIG_MATCH_1_TAG
static char * ethernet_error_strings[]
vlib_node_registration_t ethernet_input_type_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_type_node)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
void ethernet_register_l2_input(vlib_main_t *vm, u32 node_index)
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
u8 * format_ethernet_header(u8 *s, va_list *args)
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
#define VLIB_NODE_FLAG_TRACE
vlan_intf_t vlans[ETHERNET_N_VLAN]
#define SUBINT_CONFIG_MATCH_2_TAG
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define vec_elt(v, i)
Get vector value at index i.
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(ethernet_sw_interface_up_down)
static uword ethernet_input_type(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
void vlib_trace_frame_buffers_only(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, uword n_buffers, uword next_buffer_stride, uword n_buffer_data_bytes_in_trace)
void l2bvi_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
struct vnet_sub_interface_t::@91::@92::@94 flags
vlib_node_registration_t ethernet_input_node
(constructor) VLIB_REGISTER_NODE (ethernet_input_node)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
always_inline u32 eth_identify_subint(vnet_hw_interface_t *hi, vlib_buffer_t *b0, u32 match_flags, main_intf_t *main_intf, vlan_intf_t *vlan_intf, qinq_intf_t *qinq_intf, u32 *new_sw_if_index, u8 *error0, u32 *is_l2)
#define VLIB_REGISTER_NODE(x,...)
vnet_sw_interface_type_t type
always_inline vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
next_by_ethertype_t l3_next
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
static clib_error_t * ethernet_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
uword runtime_data[(128-1 *sizeof(vlib_node_function_t *)-1 *sizeof(vlib_error_t *)-11 *sizeof(u32)-5 *sizeof(u16))/sizeof(uword)]
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static_always_inline void parse_header(ethernet_input_variant_t variant, vlib_buffer_t *b0, u16 *type, u16 *orig_type, u16 *outer_id, u16 *inner_id, u32 *match_flags)
static_always_inline void identify_subint(vnet_hw_interface_t *hi, vlib_buffer_t *b0, u32 match_flags, main_intf_t *main_intf, vlan_intf_t *vlan_intf, qinq_intf_t *qinq_intf, u32 *new_sw_if_index, u8 *error0, u32 *is_l2)
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)
#define SPARSE_VEC_INVALID_INDEX
always_inline uword sparse_vec_index(void *v, uword sparse_index)