40 s =
format (s,
"VXLAN decap from vxlan_tunnel%d vni %d next %d error %d",
45 s =
format (s,
"VXLAN decap error - tunnel for vni %d does not exist",
56 u32 * fib_index_by_sw_if_index = is_ip4 ?
59 u32 fib_index = (tx_sw_if_index == (
u32) ~ 0) ?
60 vec_elt (fib_index_by_sw_if_index, sw_if_index) : tx_sw_if_index;
83 vxlan4_tunnel_key_t key4_0 = {
125 vxlan6_tunnel_key_t key6_0 = {
136 cache->
key6 = key6_0;
174 u32 pkts_decapsulated = 0;
178 last4.
key4.as_u64 = ~0;
180 memset (&last6.
key6, 0xff,
sizeof last6.
key6);
187 while (n_left_from > 0)
189 u32 * to_next, n_left_to_next;
192 while (n_left_from >= 4 && n_left_to_next >= 2)
208 u32 bi0 = to_next[0] = from[0];
209 u32 bi1 = to_next[1] = from[1];
256 u8 error0 = 0, error1 = 0;
261 next0 = VXLAN_INPUT_NEXT_DROP;
265 error0 = VXLAN_ERROR_BAD_FLAGS;
267 (drop_counter, thread_index, stats_t0->
sw_if_index, 1, len0);
270 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
284 (rx_counter, thread_index, stats_t0->
sw_if_index, 1, len0);
292 next1 = VXLAN_INPUT_NEXT_DROP;
296 error1 = VXLAN_ERROR_BAD_FLAGS;
298 (drop_counter, thread_index, stats_t1->
sw_if_index, 1, len1);
301 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
317 (rx_counter, thread_index, stats_t1->
sw_if_index, 1, len1);
338 to_next, n_left_to_next,
339 bi0, bi1, next0, next1);
342 while (n_left_from > 0 && n_left_to_next > 0)
344 u32 bi0 = to_next[0] = from[0];
379 next0 = VXLAN_INPUT_NEXT_DROP;
383 error0 = VXLAN_ERROR_BAD_FLAGS;
385 (drop_counter, thread_index, stats_t0->
sw_if_index, 1, len0);
388 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
404 (rx_counter, thread_index, stats_t0->
sw_if_index, 1, len0);
417 to_next, n_left_to_next,
448 #define vxlan_error(n,s) s, 456 .name =
"vxlan4-input",
458 .vector_size =
sizeof (
u32),
465 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 479 .name =
"vxlan6-input",
481 .vector_size =
sizeof (
u32),
488 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 514 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
529 while (n_left_from > 0)
533 while (n_left_from >= 4 && n_left_to_next >= 2)
539 u32 bi0, ip_len0, udp_len0, flags0, next0;
540 u32 bi1, ip_len1, udp_len1, flags1, next1;
541 i32 len_diff0, len_diff1;
542 u8 error0, good_udp0, proto0;
543 u8 error1, good_udp1, proto1;
559 bi0 = to_next[0] = from[0];
560 bi1 = to_next[1] = from[1];
597 if (proto0 != IP_PROTOCOL_UDP)
605 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
629 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
636 ip_len0 = clib_net_to_host_u16 (ip40->
length);
639 udp_len0 = clib_net_to_host_u16 (udp0->
length);
640 len_diff0 = ip_len0 - udp_len0;
645 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
652 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
658 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
659 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
663 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
664 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
669 b0->
error = error0 ? error_node->
errors[error0] : 0;
679 if (proto1 != IP_PROTOCOL_UDP)
687 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
711 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
718 ip_len1 = clib_net_to_host_u16 (ip41->
length);
721 udp_len1 = clib_net_to_host_u16 (udp1->
length);
722 len_diff1 = ip_len1 - udp_len1;
727 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
734 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
740 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
741 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
745 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
746 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
751 b1->
error = error1 ? error_node->
errors[error1] : 0;
761 to_next, n_left_to_next,
762 bi0, bi1, next0, next1);
765 while (n_left_from > 0 && n_left_to_next > 0)
771 u32 bi0, ip_len0, udp_len0, flags0, next0;
773 u8 error0, good_udp0, proto0;
775 bi0 = to_next[0] = from[0];
797 if (proto0 != IP_PROTOCOL_UDP)
805 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
829 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
836 ip_len0 = clib_net_to_host_u16 (ip40->
length);
839 udp_len0 = clib_net_to_host_u16 (udp0->
length);
840 len_diff0 = ip_len0 - udp_len0;
845 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
852 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
858 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
859 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
863 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
864 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
869 b0->
error = error0 ? error_node->
errors[error0] : 0;
879 to_next, n_left_to_next,
899 .name =
"ip4-vxlan-bypass",
900 .vector_size =
sizeof (
u32),
930 .name =
"ip6-vxlan-bypass",
931 .vector_size =
sizeof (
u32),
951 #define foreach_vxlan_flow_input_next \ 952 _(DROP, "error-drop") \ 953 _(L2_INPUT, "l2-input") 957 #define _(s,n) VXLAN_FLOW_NEXT_##s, 963 #define foreach_vxlan_flow_error \ 964 _(NONE, "no error") \ 965 _(IP_CHECKSUM_ERROR, "Rx ip checksum errors") \ 966 _(IP_HEADER_ERROR, "Rx ip header errors") \ 967 _(UDP_CHECKSUM_ERROR, "Rx udp checksum errors") \ 968 _(UDP_LENGTH_ERROR, "Rx udp length errors") 972 #define _(f,s) VXLAN_FLOW_ERROR_##f, 992 if ((flags & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
999 return (flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1008 u8 good_csum = (b->
flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0 ||
1018 u16 ip_len = clib_net_to_host_u16 (hdr->ip4.length);
1019 u16 expected = payload_len +
sizeof *hdr;
1020 return ip_len > expected || hdr->ip4.ttl == 0 || hdr->ip4.ip_version_and_header_length != 0x45;
1027 u16 ip_len = clib_net_to_host_u16 (hdr->ip4.length);
1028 u16 udp_len = clib_net_to_host_u16 (hdr->udp.length);
1029 return udp_len > ip_len;
1035 u8 error0 = VXLAN_FLOW_ERROR_NONE;
1037 error0 = VXLAN_FLOW_ERROR_IP_HEADER_ERROR;
1039 error0 = VXLAN_FLOW_ERROR_UDP_LENGTH_ERROR;
1041 error0 = VXLAN_FLOW_ERROR_UDP_CHECKSUM_ERROR;
1049 enum { payload_offset =
sizeof(ip4_vxlan_header_t) };
1060 u32 n_left_from = f->n_vectors;
1061 u32 next_index = VXLAN_FLOW_NEXT_L2_INPUT;
1063 while (n_left_from > 0)
1065 u32 n_left_to_next, *to_next;
1069 while (n_left_from > 3 && n_left_to_next > 3)
1071 u32 bi0 = to_next[0] = from[0];
1072 u32 bi1 = to_next[1] = from[1];
1073 u32 bi2 = to_next[2] = from[2];
1074 u32 bi3 = to_next[3] = from[3];
1095 u32 next0 = VXLAN_FLOW_NEXT_L2_INPUT, next1 = VXLAN_FLOW_NEXT_L2_INPUT,
1096 next2 = VXLAN_FLOW_NEXT_L2_INPUT, next3 = VXLAN_FLOW_NEXT_L2_INPUT;
1102 u8 ip_err = ip_err0 | ip_err1 | ip_err2 | ip_err3;
1108 u8 udp_err = udp_err0 | udp_err1 | udp_err2 | udp_err3;
1114 u8 csum_err = csum_err0 | csum_err1 | csum_err2 | csum_err3;
1126 csum_err = csum_err0 | csum_err1 | csum_err2 | csum_err3;
1131 if (ip_err0 || udp_err0 || csum_err0)
1133 next0 = VXLAN_FLOW_NEXT_DROP;
1135 b0->
error = node->errors[error0];
1137 if (ip_err1 || udp_err1 || csum_err1)
1139 next1 = VXLAN_FLOW_NEXT_DROP;
1141 b1->
error = node->errors[error1];
1143 if (ip_err2 || udp_err2 || csum_err2)
1145 next2 = VXLAN_FLOW_NEXT_DROP;
1147 b2->
error = node->errors[error2];
1149 if (ip_err3 || udp_err3 || csum_err3)
1151 next3 = VXLAN_FLOW_NEXT_DROP;
1153 b3->
error = node->errors[error3];
1197 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
1202 .
next_index = next0, .error = error0, .tunnel_index = t_index0, .vni = t0->
vni };
1204 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
1209 .
next_index = next1, .error = error1, .tunnel_index = t_index1, .vni = t1->
vni };
1211 if (b2->
flags & VLIB_BUFFER_IS_TRACED)
1216 .
next_index = next2, .error = error2, .tunnel_index = t_index2, .vni = t2->
vni };
1218 if (b3->
flags & VLIB_BUFFER_IS_TRACED)
1223 .
next_index = next3, .error = error3, .tunnel_index = t_index3, .vni = t3->
vni };
1227 (vm, node, next_index, to_next, n_left_to_next,
1228 bi0, bi1, bi2, bi3, next0, next1, next2, next3);
1230 while (n_left_from > 0 && n_left_to_next > 0)
1232 u32 bi0 = to_next[0] = from[0];
1242 u32 next0 = VXLAN_FLOW_NEXT_L2_INPUT;
1250 if (ip_err0 || udp_err0 || csum_err0)
1252 next0 = VXLAN_FLOW_NEXT_DROP;
1254 b0->
error = node->errors[error0];
1272 .
next_index = next0, .error = error0, .tunnel_index = t_index0, .vni = t0->
vni };
1275 to_next, n_left_to_next,
1282 return f->n_vectors;
1286 #ifndef CLIB_MULTIARCH_VARIANT 1288 .name =
"vxlan-flow-input",
1290 .vector_size =
sizeof (
u32),
1299 #define _(s,n) [VXLAN_FLOW_NEXT_##s] = n, static_always_inline u8 vxlan_validate_udp_csum(vlib_main_t *vm, vlib_buffer_t *b)
#define foreach_vxlan_flow_error
static u32 validate_vxlan_fib(vlib_buffer_t *b, vxlan_tunnel_t *t, u32 is_ip4)
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 char * vxlan_flow_error_strings[]
vnet_interface_main_t interface_main
vlib_node_registration_t vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_input_node)
#define foreach_vxlan_input_next
static uword vxlan_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u32 is_ip4)
#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.
vlib_node_registration_t vxlan4_flow_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_flow_input_node)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
vlib_node_registration_t ip4_vxlan_bypass_node
(constructor) VLIB_REGISTER_NODE (ip4_vxlan_bypass_node)
#define VLIB_NODE_FN(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.
static uword ip6_vxlan_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define static_always_inline
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
static uword ip6_address_is_equal(ip6_address_t *a, ip6_address_t *b)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static void * ip4_next_header(ip4_header_t *i)
static int ip4_is_fragment(ip4_header_t *i)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline u8 vxlan_check_ip_udp_len(vlib_buffer_t *b)
vlib_node_registration_t ip4_input_node
Global ip4 input node.
uword * vxlan4_tunnel_by_key
vlib_node_registration_t ip6_vxlan_bypass_node
(constructor) VLIB_REGISTER_NODE (ip6_vxlan_bypass_node)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static uword ip4_address_is_multicast(ip4_address_t *a)
u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
vlib_node_registration_t vxlan6_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_input_node)
#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.
static_always_inline void vnet_feature_next(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
#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_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static vxlan_tunnel_t * vxlan4_find_tunnel(vxlan_main_t *vxm, last_tunnel_cache4 *cache, ip4_header_t *ip4_0, vxlan_header_t *vxlan0, vxlan_tunnel_t **stats_t0)
#define VLIB_REGISTER_NODE(x,...)
static u32 vnet_get_vni(vxlan_header_t *h)
static uword vxlan4_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
u32 flow_id
Generic flow identifier.
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
static void ip6_address_set_zero(ip6_address_t *a)
static_always_inline u8 vxlan_check_udp_csum(vlib_main_t *vm, vlib_buffer_t *b)
static char * vxlan_error_strings[]
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.
static_always_inline u8 vxlan_check_ip(vlib_buffer_t *b, u16 payload_len)
static void * ip6_next_header(ip6_header_t *i)
static vxlan_tunnel_t * vxlan6_find_tunnel(vxlan_main_t *vxm, last_tunnel_cache6 *cache, ip6_header_t *ip6_0, vxlan_header_t *vxlan0, vxlan_tunnel_t **stats_t0)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define foreach_vxlan_flow_input_next
uword * vxlan6_tunnel_by_key
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
struct _vlib_node_registration vlib_node_registration_t
template key/value backing page structure
static uword ip6_address_is_multicast(ip6_address_t *a)
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)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static_always_inline u8 vxlan_err_code(u8 ip_err0, u8 udp_err0, u8 csum_err0)
u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
A collection of combined counters.
#define hash_get_mem(h, key)
VLIB_NODE_FUNCTION_MULTIARCH(l2t_decap_node, l2t_decap_node_fn)
static u8 * format_vxlan_rx_trace(u8 *s, va_list *args)
ip4_main_t ip4_main
Global ip4 main structure.
clib_error_t * ip6_vxlan_bypass_init(vlib_main_t *vm)
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static uword ip4_vxlan_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 * fib_index_by_sw_if_index
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword ip_vxlan_bypass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 is_ip4)
static uword vxlan6_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
clib_error_t * ip4_vxlan_bypass_init(vlib_main_t *vm)
u8 * format_ip6_forward_next_trace(u8 *s, va_list *args)