22 #ifndef CLIB_MARCH_VARIANT 43 return format (s,
"VXLAN decap error - tunnel for vni %d does not exist",
45 return format (s,
"VXLAN decap from vxlan_tunnel%d vni %d next %d error %d",
53 .next_index = VXLAN_INPUT_NEXT_DROP,
54 .error = VXLAN_ERROR_NO_SUCH_TUNNEL
59 .next_index = VXLAN_INPUT_NEXT_DROP,
60 .error = VXLAN_ERROR_BAD_FLAGS
80 (key4.
key[0] == cache->
key[0] && key4.
key[1] == cache->
key[1]))
189 u32 pkts_dropped = 0;
203 u32 stats_if0 = ~0, stats_if1 = ~0;
205 while (n_left_from >= 4)
323 while (n_left_from > 0)
404 #define vxlan_error(n,s) s, 412 .name =
"vxlan4-input",
413 .vector_size =
sizeof (
u32),
419 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 427 .name =
"vxlan6-input",
428 .vector_size =
sizeof (
u32),
433 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 454 u32 *from, *to_next, n_left_from, n_left_to_next, next_index;
457 vtep4_key_t last_vtep4;
459 vtep6_key_t last_vtep6;
463 #ifdef CLIB_HAVE_VEC512 482 while (n_left_from > 0)
486 while (n_left_from >= 4 && n_left_to_next >= 2)
492 u32 bi0, ip_len0, udp_len0, flags0, next0;
493 u32 bi1, ip_len1, udp_len1, flags1, next1;
494 i32 len_diff0, len_diff1;
495 u8 error0, good_udp0, proto0;
496 u8 error1, good_udp1, proto1;
507 bi0 = to_next[0] = from[0];
508 bi1 = to_next[1] = from[1];
546 if (proto0 != IP_PROTOCOL_UDP)
554 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
560 #ifdef CLIB_HAVE_VEC512 562 (&vxm->
vtep_table, b0, ip40, &last_vtep4, &vtep4_u512))
575 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
582 ip_len0 = clib_net_to_host_u16 (ip40->
length);
585 udp_len0 = clib_net_to_host_u16 (udp0->
length);
586 len_diff0 = ip_len0 - udp_len0;
595 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
600 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
601 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
605 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
606 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
611 b0->
error = error0 ? error_node->
errors[error0] : 0;
625 if (proto1 != IP_PROTOCOL_UDP)
633 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
639 #ifdef CLIB_HAVE_VEC512 641 (&vxm->
vtep_table, b1, ip41, &last_vtep4, &vtep4_u512))
654 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
661 ip_len1 = clib_net_to_host_u16 (ip41->
length);
664 udp_len1 = clib_net_to_host_u16 (udp1->
length);
665 len_diff1 = ip_len1 - udp_len1;
674 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
679 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
680 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
684 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
685 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
690 b1->
error = error1 ? error_node->
errors[error1] : 0;
704 to_next, n_left_to_next,
705 bi0, bi1, next0, next1);
708 while (n_left_from > 0 && n_left_to_next > 0)
714 u32 bi0, ip_len0, udp_len0, flags0, next0;
716 u8 error0, good_udp0, proto0;
718 bi0 = to_next[0] = from[0];
741 if (proto0 != IP_PROTOCOL_UDP)
749 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
755 #ifdef CLIB_HAVE_VEC512 757 (&vxm->
vtep_table, b0, ip40, &last_vtep4, &vtep4_u512))
770 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
777 ip_len0 = clib_net_to_host_u16 (ip40->
length);
780 udp_len0 = clib_net_to_host_u16 (udp0->
length);
781 len_diff0 = ip_len0 - udp_len0;
790 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
795 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
796 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
800 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
801 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
806 b0->
error = error0 ? error_node->
errors[error0] : 0;
820 to_next, n_left_to_next,
840 .name =
"ip4-vxlan-bypass",
841 .vector_size =
sizeof (
u32),
872 .name =
"ip6-vxlan-bypass",
873 .vector_size =
sizeof (
u32),
894 #define foreach_vxlan_flow_input_next \ 895 _(DROP, "error-drop") \ 896 _(L2_INPUT, "l2-input") 900 #define _(s,n) VXLAN_FLOW_NEXT_##s, 906 #define foreach_vxlan_flow_error \ 907 _(NONE, "no error") \ 908 _(IP_CHECKSUM_ERROR, "Rx ip checksum errors") \ 909 _(IP_HEADER_ERROR, "Rx ip header errors") \ 910 _(UDP_CHECKSUM_ERROR, "Rx udp checksum errors") \ 911 _(UDP_LENGTH_ERROR, "Rx udp length errors") 915 #define _(f,s) VXLAN_FLOW_ERROR_##f, 938 if ((flags & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
945 return (flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
954 u8 good_csum = (b->
flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0 ||
964 u16 ip_len = clib_net_to_host_u16 (hdr->ip4.length);
965 u16 expected = payload_len +
sizeof *hdr;
966 return ip_len > expected || hdr->ip4.ttl == 0
967 || hdr->ip4.ip_version_and_header_length != 0x45;
974 u16 ip_len = clib_net_to_host_u16 (hdr->ip4.length);
975 u16 udp_len = clib_net_to_host_u16 (hdr->udp.length);
976 return udp_len > ip_len;
982 u8 error0 = VXLAN_FLOW_ERROR_NONE;
984 error0 = VXLAN_FLOW_ERROR_IP_HEADER_ERROR;
986 error0 = VXLAN_FLOW_ERROR_UDP_LENGTH_ERROR;
988 error0 = VXLAN_FLOW_ERROR_UDP_CHECKSUM_ERROR;
997 { payload_offset =
sizeof (ip4_vxlan_header_t) };
1002 [VXLAN_FLOW_NEXT_DROP] =
1004 [VXLAN_FLOW_NEXT_L2_INPUT] =
1010 u32 n_left_from = f->n_vectors;
1011 u32 next_index = VXLAN_FLOW_NEXT_L2_INPUT;
1013 while (n_left_from > 0)
1015 u32 n_left_to_next, *to_next;
1019 while (n_left_from > 3 && n_left_to_next > 3)
1021 u32 bi0 = to_next[0] = from[0];
1022 u32 bi1 = to_next[1] = from[1];
1023 u32 bi2 = to_next[2] = from[2];
1024 u32 bi3 = to_next[3] = from[3];
1028 n_left_to_next -= 4;
1045 u32 next0 = VXLAN_FLOW_NEXT_L2_INPUT, next1 =
1046 VXLAN_FLOW_NEXT_L2_INPUT, next2 =
1047 VXLAN_FLOW_NEXT_L2_INPUT, next3 = VXLAN_FLOW_NEXT_L2_INPUT;
1053 u8 ip_err = ip_err0 | ip_err1 | ip_err2 | ip_err3;
1059 u8 udp_err = udp_err0 | udp_err1 | udp_err2 | udp_err3;
1065 u8 csum_err = csum_err0 | csum_err1 | csum_err2 | csum_err3;
1077 csum_err = csum_err0 | csum_err1 | csum_err2 | csum_err3;
1082 if (ip_err0 || udp_err0 || csum_err0)
1084 next0 = VXLAN_FLOW_NEXT_DROP;
1088 if (ip_err1 || udp_err1 || csum_err1)
1090 next1 = VXLAN_FLOW_NEXT_DROP;
1094 if (ip_err2 || udp_err2 || csum_err2)
1096 next2 = VXLAN_FLOW_NEXT_DROP;
1100 if (ip_err3 || udp_err3 || csum_err3)
1102 next3 = VXLAN_FLOW_NEXT_DROP;
1144 sw_if_index0, 1, len0);
1146 sw_if_index1, 1, len1);
1148 sw_if_index2, 1, len2);
1150 sw_if_index3, 1, len3);
1156 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
1166 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
1176 if (b2->
flags & VLIB_BUFFER_IS_TRACED)
1186 if (b3->
flags & VLIB_BUFFER_IS_TRACED)
1198 (vm,
node, next_index, to_next, n_left_to_next,
1199 bi0, bi1, bi2, bi3, next0, next1, next2, next3);
1201 while (n_left_from > 0 && n_left_to_next > 0)
1203 u32 bi0 = to_next[0] = from[0];
1213 u32 next0 = VXLAN_FLOW_NEXT_L2_INPUT;
1221 if (ip_err0 || udp_err0 || csum_err0)
1223 next0 = VXLAN_FLOW_NEXT_DROP;
1238 sw_if_index0, 1, len0);
1251 to_next, n_left_to_next,
1258 return f->n_vectors;
1262 #ifndef CLIB_MULTIARCH_VARIANT 1264 .name =
"vxlan-flow-input",
1266 .vector_size =
sizeof (
u32),
1275 #define _(s,n) [VXLAN_FLOW_NEXT_##s] = n, u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vlib_node_registration_t vxlan6_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_input_node)
static uword ip_vxlan_bypass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 is_ip4)
static uword vxlan_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u32 is_ip4)
vl_api_wireguard_peer_flags_t flags
clib_bihash_24_8_t vxlan6_tunnel_by_key
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static_always_inline u8 vxlan_check_ip(vlib_buffer_t *b, u16 payload_len)
static vxlan_decap_info_t vxlan6_find_tunnel(vxlan_main_t *vxm, last_tunnel_cache6 *cache, u32 fib_index, ip6_header_t *ip6_0, vxlan_header_t *vxlan0, u32 *stats_sw_if_index)
vnet_interface_main_t interface_main
#define foreach_vxlan_input_next
vlib_node_registration_t vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_input_node)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#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.
#define VLIB_NODE_FN(node)
static uword ip4_address_is_multicast(const ip4_address_t *a)
vlib_node_registration_t ip4_vxlan_bypass_node
(constructor) VLIB_REGISTER_NODE (ip4_vxlan_bypass_node)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
vlib_node_registration_t ip6_vxlan_bypass_node
(constructor) VLIB_REGISTER_NODE (ip6_vxlan_bypass_node)
static const vxlan_decap_info_t decap_not_found
static u32 vlib_buffer_get_ip_fib_index(vlib_buffer_t *b, u8 is_ip4)
static int ip4_is_fragment(const ip4_header_t *i)
static int clib_bihash_key_compare_24_8(u64 *a, u64 *b)
#define static_always_inline
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
description fragment has unexpected format
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static vxlan_decap_info_t vxlan4_find_tunnel(vxlan_main_t *vxm, last_tunnel_cache4 *cache, u32 fib_index, ip4_header_t *ip4_0, vxlan_header_t *vxlan0, u32 *stats_sw_if_index)
static void * ip4_next_header(ip4_header_t *i)
static_always_inline u8 vxlan_err_code(u8 ip_err0, u8 udp_err0, u8 csum_err0)
static void vtep4_key_init(vtep4_key_t *k4)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_node_registration_t ip4_input_node
Global ip4 input node.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
static u8 * format_vxlan_rx_trace(u8 *s, va_list *args)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#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).
vlib_node_registration_t vxlan4_flow_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_flow_input_node)
static u8 vtep6_check(vtep_table_t *t, vlib_buffer_t *b0, ip6_header_t *ip60, vtep6_key_t *last_k6)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static u8 vtep4_check(vtep_table_t *t, vlib_buffer_t *b0, ip4_header_t *ip40, vtep4_key_t *last_k4)
static const vxlan_decap_info_t decap_bad_flags
#define VLIB_REGISTER_NODE(x,...)
static u32 vnet_get_vni(vxlan_header_t *h)
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
vxlan6_tunnel_key_t last_tunnel_cache6
u32 flow_id
Generic flow identifier.
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
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.
#define foreach_vxlan_flow_error
static clib_error_t * ip6_vxlan_bypass_init(vlib_main_t *vm)
static void * ip6_next_header(ip6_header_t *i)
vlib_main_t vlib_node_runtime_t * node
static char * vxlan_flow_error_strings[]
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static clib_error_t * ip4_vxlan_bypass_init(vlib_main_t *vm)
static void vtep6_key_init(vtep6_key_t *k6)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static_always_inline u8 vxlan_validate_udp_csum(vlib_main_t *vm, vlib_buffer_t *b)
static uword ip6_address_is_equal(const ip6_address_t *a, const ip6_address_t *b)
static uword ip6_address_is_multicast(const ip6_address_t *a)
struct _vlib_node_registration vlib_node_registration_t
template key/value backing page structure
u32 ip6_tcp_udp_icmp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
void ip4_forward_next_trace(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, vlib_rx_or_tx_t which_adj_index)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
VLIB buffer representation.
vxlan4_tunnel_key_t last_tunnel_cache4
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
A collection of combined counters.
static_always_inline u8 vxlan_check_ip_udp_len(vlib_buffer_t *b)
u32 * tunnel_index_by_sw_if_index
#define foreach_vxlan_flow_input_next
clib_bihash_16_8_t vxlan4_tunnel_by_key
static_always_inline u8 vxlan_check_udp_csum(vlib_main_t *vm, vlib_buffer_t *b)
u16 flags
Copy of main node flags.
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 CLIB_CACHE_LINE_BYTES
static char * vxlan_error_strings[]
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u8 vtep4_check_vector(vtep_table_t *t, vlib_buffer_t *b0, ip4_header_t *ip40, vtep4_key_t *last_k4, vtep4_cache_t *vtep4_u512)
u8 * format_ip6_forward_next_trace(u8 *s, va_list *args)