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",
54 u32 fib_index, sw_if_index;
76 u32 n_left_from, next_index, * from, * to_next;
80 u32 last_tunnel_index = ~0;
81 vxlan4_tunnel_key_t last_key4;
82 vxlan6_tunnel_key_t last_key6;
83 u32 pkts_decapsulated = 0;
85 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
88 last_key4.as_u64 = ~0;
90 memset (&last_key6, 0xff,
sizeof (last_key6));
97 stats_n_packets = stats_n_bytes = 0;
99 while (n_left_from > 0)
104 to_next, n_left_to_next);
105 while (n_left_from >= 4 && n_left_to_next >= 2)
114 u32 tunnel_index0, tunnel_index1;
116 vxlan4_tunnel_key_t key4_0, key4_1;
117 vxlan6_tunnel_key_t key6_0, key6_1;
119 u32 sw_if_index0, sw_if_index1, len0, len1;
169 (b0,
sizeof(*ip4_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
171 (b1,
sizeof(*ip4_1)+
sizeof(
udp_header_t)+
sizeof(*vxlan1));
174 (b0,
sizeof(*ip6_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
176 (b1,
sizeof(*ip6_1)+
sizeof(
udp_header_t)+
sizeof(*vxlan1));
187 error0 = VXLAN_ERROR_BAD_FLAGS;
188 next0 = VXLAN_INPUT_NEXT_DROP;
202 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
203 next0 = VXLAN_INPUT_NEXT_DROP;
206 last_key4.as_u64 = key4_0.as_u64;
207 tunnel_index0 = last_tunnel_index = p0[0];
210 tunnel_index0 = last_tunnel_index;
216 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
217 next0 = VXLAN_INPUT_NEXT_DROP;
236 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
237 next0 = VXLAN_INPUT_NEXT_DROP;
246 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
251 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
252 next0 = VXLAN_INPUT_NEXT_DROP;
256 tunnel_index0 = last_tunnel_index = p0[0];
259 tunnel_index0 = last_tunnel_index;
265 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
266 next0 = VXLAN_INPUT_NEXT_DROP;
286 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
287 next0 = VXLAN_INPUT_NEXT_DROP;
302 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
304 pkts_decapsulated ++;
305 stats_n_packets += 1;
306 stats_n_bytes += len0;
312 stats_n_packets -= 1;
313 stats_n_bytes -= len0;
317 thread_index, stats_sw_if_index,
318 stats_n_packets, stats_n_bytes);
320 stats_n_bytes = len0;
321 stats_sw_if_index = sw_if_index0;
339 error1 = VXLAN_ERROR_BAD_FLAGS;
340 next1 = VXLAN_INPUT_NEXT_DROP;
354 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
355 next1 = VXLAN_INPUT_NEXT_DROP;
358 last_key4.as_u64 = key4_1.as_u64;
359 tunnel_index1 = last_tunnel_index = p1[0];
362 tunnel_index1 = last_tunnel_index;
368 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
369 next1 = VXLAN_INPUT_NEXT_DROP;
388 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
389 next1 = VXLAN_INPUT_NEXT_DROP;
398 if (
PREDICT_FALSE (memcmp(&key6_1, &last_key6,
sizeof(last_key6)) != 0))
404 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
405 next1 = VXLAN_INPUT_NEXT_DROP;
410 tunnel_index1 = last_tunnel_index = p1[0];
413 tunnel_index1 = last_tunnel_index;
419 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
420 next1 = VXLAN_INPUT_NEXT_DROP;
440 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
441 next1 = VXLAN_INPUT_NEXT_DROP;
456 sw_if_index1 = (mt1) ? mt1->sw_if_index : sw_if_index1;
458 pkts_decapsulated ++;
459 stats_n_packets += 1;
460 stats_n_bytes += len1;
466 stats_n_packets -= 1;
467 stats_n_bytes -= len1;
471 thread_index, stats_sw_if_index,
472 stats_n_packets, stats_n_bytes);
474 stats_n_bytes = len1;
475 stats_sw_if_index = sw_if_index1;
492 to_next, n_left_to_next,
493 bi0, bi1, next0, next1);
496 while (n_left_from > 0 && n_left_to_next > 0)
507 vxlan4_tunnel_key_t key4_0;
508 vxlan6_tunnel_key_t key6_0;
510 u32 sw_if_index0, len0;
536 (b0,
sizeof(*ip4_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
539 (b0,
sizeof(*ip6_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
547 error0 = VXLAN_ERROR_BAD_FLAGS;
548 next0 = VXLAN_INPUT_NEXT_DROP;
562 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
563 next0 = VXLAN_INPUT_NEXT_DROP;
566 last_key4.as_u64 = key4_0.as_u64;
567 tunnel_index0 = last_tunnel_index = p0[0];
570 tunnel_index0 = last_tunnel_index;
576 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
577 next0 = VXLAN_INPUT_NEXT_DROP;
596 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
597 next0 = VXLAN_INPUT_NEXT_DROP;
606 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
611 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
612 next0 = VXLAN_INPUT_NEXT_DROP;
616 tunnel_index0 = last_tunnel_index = p0[0];
619 tunnel_index0 = last_tunnel_index;
625 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
626 next0 = VXLAN_INPUT_NEXT_DROP;
646 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
647 next0 = VXLAN_INPUT_NEXT_DROP;
662 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
664 pkts_decapsulated ++;
665 stats_n_packets += 1;
666 stats_n_bytes += len0;
672 stats_n_packets -= 1;
673 stats_n_bytes -= len0;
677 thread_index, stats_sw_if_index,
678 stats_n_packets, stats_n_bytes);
680 stats_n_bytes = len0;
681 stats_sw_if_index = sw_if_index0;
697 to_next, n_left_to_next,
706 VXLAN_ERROR_DECAPSULATED,
714 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
738 #define vxlan_error(n,s) s, 746 .name =
"vxlan4-input",
748 .vector_size =
sizeof (
u32),
755 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 769 .name =
"vxlan6-input",
771 .vector_size =
sizeof (
u32),
778 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 804 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
819 while (n_left_from > 0)
823 while (n_left_from >= 4 && n_left_to_next >= 2)
829 u32 bi0, ip_len0, udp_len0, flags0, next0;
830 u32 bi1, ip_len1, udp_len1, flags1, next1;
831 i32 len_diff0, len_diff1;
832 u8 error0, good_udp0, proto0;
833 u8 error1, good_udp1, proto1;
849 bi0 = to_next[0] = from[0];
850 bi1 = to_next[1] = from[1];
887 if (proto0 != IP_PROTOCOL_UDP)
895 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
919 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
926 ip_len0 = clib_net_to_host_u16 (ip40->
length);
929 udp_len0 = clib_net_to_host_u16 (udp0->
length);
930 len_diff0 = ip_len0 - udp_len0;
935 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
942 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
948 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
949 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
953 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
954 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
959 b0->
error = error0 ? error_node->
errors[error0] : 0;
969 if (proto1 != IP_PROTOCOL_UDP)
977 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
1001 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1008 ip_len1 = clib_net_to_host_u16 (ip41->
length);
1011 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1012 len_diff1 = ip_len1 - udp_len1;
1017 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1024 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1030 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1031 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1035 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1036 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1041 b1->
error = error1 ? error_node->
errors[error1] : 0;
1051 to_next, n_left_to_next,
1052 bi0, bi1, next0, next1);
1055 while (n_left_from > 0 && n_left_to_next > 0)
1061 u32 bi0, ip_len0, udp_len0, flags0, next0;
1063 u8 error0, good_udp0, proto0;
1065 bi0 = to_next[0] = from[0];
1069 n_left_to_next -= 1;
1087 if (proto0 != IP_PROTOCOL_UDP)
1095 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
1119 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1126 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1129 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1130 len_diff0 = ip_len0 - udp_len0;
1135 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1142 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1148 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1149 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1153 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1154 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1159 b0->
error = error0 ? error_node->
errors[error0] : 0;
1169 to_next, n_left_to_next,
1189 .name =
"ip4-vxlan-bypass",
1190 .vector_size =
sizeof (
u32),
1220 .name =
"ip6-vxlan-bypass",
1221 .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)
struct _vlib_node_registration vlib_node_registration_t
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)
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[]
#define VLIB_BUFFER_IS_TRACED
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.
#define VLIB_NODE_FLAG_TRACE
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.
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)
#define VLIB_REGISTER_NODE(x,...)
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 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)