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;
74 u32 last_tunnel_index = ~0;
75 vxlan4_tunnel_key_t last_key4;
76 vxlan6_tunnel_key_t last_key6;
77 u32 pkts_decapsulated = 0;
81 last_key4.as_u64 = ~0;
83 memset (&last_key6, 0xff,
sizeof (last_key6));
87 u32 stats_n_packets = 0, stats_n_bytes = 0;
92 while (n_left_from > 0)
94 u32 * to_next, n_left_to_next;
96 to_next, n_left_to_next);
98 while (n_left_from >= 4 && n_left_to_next >= 2)
151 u32 tunnel_index0 = ~0, tunnel_index1 = ~0;
152 u32 error0 = 0, error1 = 0;
156 error0 = VXLAN_ERROR_BAD_FLAGS;
157 next0 = VXLAN_INPUT_NEXT_DROP;
164 vxlan4_tunnel_key_t key4_0 = {
174 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
175 next0 = VXLAN_INPUT_NEXT_DROP;
179 last_tunnel_index = p[0];
181 tunnel_index0 = last_tunnel_index;
187 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
188 next0 = VXLAN_INPUT_NEXT_DROP;
206 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
207 next0 = VXLAN_INPUT_NEXT_DROP;
212 vxlan6_tunnel_key_t key6_0 = {
217 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
222 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
223 next0 = VXLAN_INPUT_NEXT_DROP;
227 last_tunnel_index = p[0];
229 tunnel_index0 = last_tunnel_index;
235 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
236 next0 = VXLAN_INPUT_NEXT_DROP;
254 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
255 next0 = VXLAN_INPUT_NEXT_DROP;
279 thread_index, stats_sw_if_index,
280 stats_n_packets, stats_n_bytes);
281 pkts_decapsulated += stats_n_packets;
282 stats_n_packets = stats_n_bytes = 0;
284 stats_sw_if_index = sw_if_index0;
286 stats_n_packets += 1;
287 stats_n_bytes += len0;
304 error1 = VXLAN_ERROR_BAD_FLAGS;
305 next1 = VXLAN_INPUT_NEXT_DROP;
311 vxlan4_tunnel_key_t key4_1 = {
321 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
322 next1 = VXLAN_INPUT_NEXT_DROP;
326 last_tunnel_index = p[0];
328 tunnel_index1 = last_tunnel_index;
334 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
335 next1 = VXLAN_INPUT_NEXT_DROP;
354 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
355 next1 = VXLAN_INPUT_NEXT_DROP;
360 vxlan6_tunnel_key_t key6_1 = {
365 if (
PREDICT_FALSE (memcmp(&key6_1, &last_key6,
sizeof(last_key6)) != 0))
370 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
371 next1 = VXLAN_INPUT_NEXT_DROP;
376 last_tunnel_index = p[0];
378 tunnel_index1 = last_tunnel_index;
384 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
385 next1 = VXLAN_INPUT_NEXT_DROP;
404 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
405 next1 = VXLAN_INPUT_NEXT_DROP;
429 thread_index, stats_sw_if_index,
430 stats_n_packets, stats_n_bytes);
431 pkts_decapsulated += stats_n_packets;
432 stats_n_packets = stats_n_bytes = 0;
434 stats_sw_if_index = sw_if_index1;
436 stats_n_packets += 1;
437 stats_n_bytes += len1;
453 to_next, n_left_to_next,
454 bi0, bi1, next0, next1);
457 while (n_left_from > 0 && n_left_to_next > 0)
486 u32 tunnel_index0 = ~0;
491 error0 = VXLAN_ERROR_BAD_FLAGS;
492 next0 = VXLAN_INPUT_NEXT_DROP;
497 vxlan4_tunnel_key_t key4_0 = {
508 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
509 next0 = VXLAN_INPUT_NEXT_DROP;
513 last_tunnel_index = p[0];
515 tunnel_index0 = last_tunnel_index;
521 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
522 next0 = VXLAN_INPUT_NEXT_DROP;
540 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
541 next0 = VXLAN_INPUT_NEXT_DROP;
546 vxlan6_tunnel_key_t key6_0 = {
551 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
556 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
557 next0 = VXLAN_INPUT_NEXT_DROP;
561 last_tunnel_index = p[0];
563 tunnel_index0 = last_tunnel_index;
569 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
570 next0 = VXLAN_INPUT_NEXT_DROP;
588 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
589 next0 = VXLAN_INPUT_NEXT_DROP;
613 thread_index, stats_sw_if_index,
614 stats_n_packets, stats_n_bytes);
615 pkts_decapsulated += stats_n_packets;
616 stats_n_packets = stats_n_bytes = 0;
618 stats_sw_if_index = sw_if_index0;
620 stats_n_packets += 1;
621 stats_n_bytes += len0;
637 to_next, n_left_to_next,
646 pkts_decapsulated += stats_n_packets;
649 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
678 #define vxlan_error(n,s) s, 686 .name =
"vxlan4-input",
688 .vector_size =
sizeof (
u32),
695 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 709 .name =
"vxlan6-input",
711 .vector_size =
sizeof (
u32),
718 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 744 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
759 while (n_left_from > 0)
763 while (n_left_from >= 4 && n_left_to_next >= 2)
769 u32 bi0, ip_len0, udp_len0, flags0, next0;
770 u32 bi1, ip_len1, udp_len1, flags1, next1;
771 i32 len_diff0, len_diff1;
772 u8 error0, good_udp0, proto0;
773 u8 error1, good_udp1, proto1;
789 bi0 = to_next[0] = from[0];
790 bi1 = to_next[1] = from[1];
827 if (proto0 != IP_PROTOCOL_UDP)
835 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
859 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
866 ip_len0 = clib_net_to_host_u16 (ip40->
length);
869 udp_len0 = clib_net_to_host_u16 (udp0->
length);
870 len_diff0 = ip_len0 - udp_len0;
875 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
882 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
888 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
889 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
893 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
894 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
899 b0->
error = error0 ? error_node->
errors[error0] : 0;
909 if (proto1 != IP_PROTOCOL_UDP)
917 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
941 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
948 ip_len1 = clib_net_to_host_u16 (ip41->
length);
951 udp_len1 = clib_net_to_host_u16 (udp1->
length);
952 len_diff1 = ip_len1 - udp_len1;
957 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
964 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
970 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
971 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
975 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
976 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
981 b1->
error = error1 ? error_node->
errors[error1] : 0;
991 to_next, n_left_to_next,
992 bi0, bi1, next0, next1);
995 while (n_left_from > 0 && n_left_to_next > 0)
1001 u32 bi0, ip_len0, udp_len0, flags0, next0;
1003 u8 error0, good_udp0, proto0;
1005 bi0 = to_next[0] = from[0];
1009 n_left_to_next -= 1;
1027 if (proto0 != IP_PROTOCOL_UDP)
1035 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
1059 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1066 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1069 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1070 len_diff0 = ip_len0 - udp_len0;
1075 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1082 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1088 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1089 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1093 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1094 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1099 b0->
error = error0 ? error_node->
errors[error0] : 0;
1109 to_next, n_left_to_next,
1129 .name =
"ip4-vxlan-bypass",
1130 .vector_size =
sizeof (
u32),
1160 .name =
"ip6-vxlan-bypass",
1161 .vector_size =
sizeof (
u32),
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.
u8 runtime_data[0]
Function dependent node-runtime data.
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)
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)
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 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.
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)
#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)
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 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.
#define clib_memcpy(a, b, c)
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)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
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
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.
u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
#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)