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",
57 u32 n_left_from, next_index, * from, * to_next;
61 u32 last_tunnel_index = ~0;
62 vxlan4_tunnel_key_t last_key4;
63 vxlan6_tunnel_key_t last_key6;
64 u32 pkts_decapsulated = 0;
66 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
69 last_key4.as_u64 = ~0;
71 memset (&last_key6, 0xff,
sizeof (last_key6));
78 stats_n_packets = stats_n_bytes = 0;
80 while (n_left_from > 0)
85 to_next, n_left_to_next);
86 while (n_left_from >= 4 && n_left_to_next >= 2)
95 u32 tunnel_index0, tunnel_index1;
97 vxlan4_tunnel_key_t key4_0, key4_1;
98 vxlan6_tunnel_key_t key6_0, key6_1;
100 u32 sw_if_index0, sw_if_index1, len0, len1;
150 (b0,
sizeof(*ip4_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
152 (b1,
sizeof(*ip4_1)+
sizeof(
udp_header_t)+
sizeof(*vxlan1));
155 (b0,
sizeof(*ip6_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
157 (b1,
sizeof(*ip6_1)+
sizeof(
udp_header_t)+
sizeof(*vxlan1));
168 error0 = VXLAN_ERROR_BAD_FLAGS;
169 next0 = VXLAN_INPUT_NEXT_DROP;
183 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
184 next0 = VXLAN_INPUT_NEXT_DROP;
187 last_key4.as_u64 = key4_0.as_u64;
188 tunnel_index0 = last_tunnel_index = p0[0];
191 tunnel_index0 = last_tunnel_index;
209 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
210 next0 = VXLAN_INPUT_NEXT_DROP;
219 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
224 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
225 next0 = VXLAN_INPUT_NEXT_DROP;
229 tunnel_index0 = last_tunnel_index = p0[0];
232 tunnel_index0 = last_tunnel_index;
251 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
252 next0 = VXLAN_INPUT_NEXT_DROP;
267 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
269 pkts_decapsulated ++;
270 stats_n_packets += 1;
271 stats_n_bytes += len0;
277 stats_n_packets -= 1;
278 stats_n_bytes -= len0;
282 cpu_index, stats_sw_if_index,
283 stats_n_packets, stats_n_bytes);
285 stats_n_bytes = len0;
286 stats_sw_if_index = sw_if_index0;
304 error1 = VXLAN_ERROR_BAD_FLAGS;
305 next1 = VXLAN_INPUT_NEXT_DROP;
319 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
320 next1 = VXLAN_INPUT_NEXT_DROP;
323 last_key4.as_u64 = key4_1.as_u64;
324 tunnel_index1 = last_tunnel_index = p1[0];
327 tunnel_index1 = last_tunnel_index;
345 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
346 next1 = VXLAN_INPUT_NEXT_DROP;
355 if (
PREDICT_FALSE (memcmp(&key6_1, &last_key6,
sizeof(last_key6)) != 0))
361 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
362 next1 = VXLAN_INPUT_NEXT_DROP;
367 tunnel_index1 = last_tunnel_index = p1[0];
370 tunnel_index1 = last_tunnel_index;
389 error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
390 next1 = VXLAN_INPUT_NEXT_DROP;
405 sw_if_index1 = (mt1) ? mt1->sw_if_index : sw_if_index1;
407 pkts_decapsulated ++;
408 stats_n_packets += 1;
409 stats_n_bytes += len1;
415 stats_n_packets -= 1;
416 stats_n_bytes -= len1;
420 cpu_index, stats_sw_if_index,
421 stats_n_packets, stats_n_bytes);
423 stats_n_bytes = len1;
424 stats_sw_if_index = sw_if_index1;
441 to_next, n_left_to_next,
442 bi0, bi1, next0, next1);
445 while (n_left_from > 0 && n_left_to_next > 0)
456 vxlan4_tunnel_key_t key4_0;
457 vxlan6_tunnel_key_t key6_0;
459 u32 sw_if_index0, len0;
485 (b0,
sizeof(*ip4_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
488 (b0,
sizeof(*ip6_0)+
sizeof(
udp_header_t)+
sizeof(*vxlan0));
496 error0 = VXLAN_ERROR_BAD_FLAGS;
497 next0 = VXLAN_INPUT_NEXT_DROP;
511 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
512 next0 = VXLAN_INPUT_NEXT_DROP;
515 last_key4.as_u64 = key4_0.as_u64;
516 tunnel_index0 = last_tunnel_index = p0[0];
519 tunnel_index0 = last_tunnel_index;
537 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
538 next0 = VXLAN_INPUT_NEXT_DROP;
547 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
552 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
553 next0 = VXLAN_INPUT_NEXT_DROP;
557 tunnel_index0 = last_tunnel_index = p0[0];
560 tunnel_index0 = last_tunnel_index;
579 error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
580 next0 = VXLAN_INPUT_NEXT_DROP;
595 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
597 pkts_decapsulated ++;
598 stats_n_packets += 1;
599 stats_n_bytes += len0;
605 stats_n_packets -= 1;
606 stats_n_bytes -= len0;
610 cpu_index, stats_sw_if_index,
611 stats_n_packets, stats_n_bytes);
613 stats_n_bytes = len0;
614 stats_sw_if_index = sw_if_index0;
630 to_next, n_left_to_next,
639 VXLAN_ERROR_DECAPSULATED,
647 cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
671 #define vxlan_error(n,s) s, 679 .name =
"vxlan4-input",
681 .vector_size =
sizeof (
u32),
683 .n_errors = VXLAN_N_ERROR,
688 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 702 .name =
"vxlan6-input",
704 .vector_size =
sizeof (
u32),
706 .n_errors = VXLAN_N_ERROR,
711 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n, 737 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
752 while (n_left_from > 0)
756 while (n_left_from >= 4 && n_left_to_next >= 2)
761 u32 bi0, ip_len0, udp_len0, flags0, next0;
762 u32 bi1, ip_len1, udp_len1, flags1, next1;
763 i32 len_diff0, len_diff1;
764 u8 error0, good_udp0, proto0;
765 u8 error1, good_udp1, proto1;
781 bi0 = to_next[0] = from[0];
782 bi1 = to_next[1] = from[1];
803 if (proto0 != IP_PROTOCOL_UDP)
807 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
831 ip_len0 = clib_net_to_host_u16 (ip0->
length);
832 udp_len0 = clib_net_to_host_u16 (udp0->
length);
834 len_diff0 = ip_len0 - udp_len0;
845 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
846 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
850 b0->
error = error0 ? error_node->
errors[error0] : 0;
854 if (proto1 != IP_PROTOCOL_UDP)
858 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
882 ip_len1 = clib_net_to_host_u16 (ip1->
length);
883 udp_len1 = clib_net_to_host_u16 (udp1->
length);
885 len_diff1 = ip_len1 - udp_len1;
896 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
897 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
901 b1->
error = error1 ? error_node->
errors[error1] : 0;
905 to_next, n_left_to_next,
906 bi0, bi1, next0, next1);
909 while (n_left_from > 0 && n_left_to_next > 0)
914 u32 bi0, ip_len0, udp_len0, flags0, next0;
916 u8 error0, good_udp0, proto0;
918 bi0 = to_next[0] = from[0];
934 if (proto0 != IP_PROTOCOL_UDP)
938 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_vxlan))
962 ip_len0 = clib_net_to_host_u16 (ip0->
length);
963 udp_len0 = clib_net_to_host_u16 (udp0->
length);
965 len_diff0 = ip_len0 - udp_len0;
976 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
977 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
981 b0->
error = error0 ? error_node->
errors[error0] : 0;
985 to_next, n_left_to_next,
1005 .name =
"ip4-vxlan-bypass",
1006 .vector_size =
sizeof (
u32),
1029 u32 sw_if_index, is_del;
1041 else if (
unformat (line_input,
"del"))
1050 if (~0 == sw_if_index)
1121 .path =
"set interface ip vxlan-bypass",
1123 .short_help =
"set interface ip vxlan-bypass <interface> [del]",
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.
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
unformat_function_t unformat_vnet_sw_interface
vlib_node_registration_t ip4_vxlan_bypass_node
(constructor) VLIB_REGISTER_NODE (ip4_vxlan_bypass_node)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vlib_combined_counter_main_t * combined_sw_if_counters
#define IP_BUFFER_L4_CHECKSUM_CORRECT
static uword ip6_address_is_equal(ip6_address_t *a, ip6_address_t *b)
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
uword os_get_cpu_number(void)
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)
#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)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define VLIB_CLI_COMMAND(x,...)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
uword * vxlan6_tunnel_by_key
#define VLIB_NODE_FLAG_TRACE
#define VLIB_BUFFER_IS_TRACED
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static clib_error_t * set_ip_vxlan_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define IP_BUFFER_L4_CHECKSUM_COMPUTED
static uword ip6_address_is_multicast(ip6_address_t *a)
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)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
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,...)
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: 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)
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)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
clib_error_t * ip4_vxlan_bypass_init(vlib_main_t *vm)