110 u32 n_left_from, next_index, *from, *to_next;
114 u32 last_tunnel_index = ~0;
115 vxlan4_gpe_tunnel_key_t last_key4;
116 vxlan6_gpe_tunnel_key_t last_key6;
117 u32 pkts_decapsulated = 0;
119 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
122 clib_memset (&last_key4, 0xff,
sizeof (last_key4));
124 clib_memset (&last_key6, 0xff,
sizeof (last_key6));
131 stats_n_packets = stats_n_bytes = 0;
133 while (n_left_from > 0)
139 while (n_left_from >= 4 && n_left_to_next >= 2)
144 ip4_vxlan_gpe_header_t *iuvn4_0, *iuvn4_1;
145 ip6_vxlan_gpe_header_t *iuvn6_0, *iuvn6_1;
147 u32 tunnel_index0, tunnel_index1;
149 vxlan4_gpe_tunnel_key_t key4_0, key4_1;
150 vxlan6_gpe_tunnel_key_t key6_0, key6_1;
152 u32 sw_if_index0, sw_if_index1, len0, len1;
225 VXLAN_GPE_INPUT_NEXT_DROP;
229 VXLAN_GPE_INPUT_NEXT_DROP;
231 key4_0.local = iuvn4_0->ip4.dst_address.as_u32;
232 key4_1.local = iuvn4_1->ip4.dst_address.as_u32;
234 key4_0.remote = iuvn4_0->ip4.src_address.as_u32;
235 key4_1.remote = iuvn4_1->ip4.src_address.as_u32;
237 key4_0.vni = iuvn4_0->vxlan.vni_res;
238 key4_1.vni = iuvn4_1->vxlan.vni_res;
245 next0 = (iuvn6_0->vxlan.protocol < node->
n_next_nodes) ?
246 iuvn6_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
247 next1 = (iuvn6_1->vxlan.protocol < node->
n_next_nodes) ?
248 iuvn6_1->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
250 key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
251 key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
252 key6_1.local.as_u64[0] = iuvn6_1->ip6.dst_address.as_u64[0];
253 key6_1.local.as_u64[1] = iuvn6_1->ip6.dst_address.as_u64[1];
255 key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
256 key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
257 key6_1.remote.as_u64[0] = iuvn6_1->ip6.src_address.as_u64[0];
258 key6_1.remote.as_u64[1] = iuvn6_1->ip6.src_address.as_u64[1];
260 key6_0.vni = iuvn6_0->vxlan.vni_res;
261 key6_1.vni = iuvn6_1->vxlan.vni_res;
269 || (key4_0.as_u64[1] !=
270 last_key4.as_u64[1])))
276 error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
280 last_key4.as_u64[0] = key4_0.as_u64[0];
281 last_key4.as_u64[1] = key4_0.as_u64[1];
282 tunnel_index0 = last_tunnel_index = p0[0];
285 tunnel_index0 = last_tunnel_index;
292 VXLAN_GPE_INPUT_NEXT_DROP;
296 VXLAN_GPE_INPUT_NEXT_DROP;
298 key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
299 key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
300 key6_1.local.as_u64[0] = iuvn6_1->ip6.dst_address.as_u64[0];
301 key6_1.local.as_u64[1] = iuvn6_1->ip6.dst_address.as_u64[1];
303 key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
304 key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
305 key6_1.remote.as_u64[0] = iuvn6_1->ip6.src_address.as_u64[0];
306 key6_1.remote.as_u64[1] = iuvn6_1->ip6.src_address.as_u64[1];
308 key6_0.vni = iuvn6_0->vxlan.vni_res;
309 key6_1.vni = iuvn6_1->vxlan.vni_res;
313 (memcmp (&key6_0, &last_key6,
sizeof (last_key6)) != 0))
319 error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
323 memcpy (&last_key6, &key6_0,
sizeof (key6_0));
324 tunnel_index0 = last_tunnel_index = p0[0];
327 tunnel_index0 = last_tunnel_index;
348 stats_n_packets += 1;
349 stats_n_bytes += len0;
353 stats_n_packets -= 1;
354 stats_n_bytes -= len0;
363 stats_n_bytes = len0;
364 stats_sw_if_index = sw_if_index0;
367 trace0:b0->
error = error0 ? node->
errors[error0] : 0;
383 || (key4_1.as_u64[1] !=
384 last_key4.as_u64[1])))
390 error1 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
394 last_key4.as_u64[0] = key4_1.as_u64[0];
395 last_key4.as_u64[1] = key4_1.as_u64[1];
396 tunnel_index1 = last_tunnel_index = p1[0];
399 tunnel_index1 = last_tunnel_index;
405 (memcmp (&key6_1, &last_key6,
sizeof (last_key6)) != 0))
411 error1 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
415 memcpy (&last_key6, &key6_1,
sizeof (key6_1));
416 tunnel_index1 = last_tunnel_index = p1[0];
419 tunnel_index1 = last_tunnel_index;
439 stats_n_packets += 1;
440 stats_n_bytes += len1;
446 stats_n_packets -= 1;
447 stats_n_bytes -= len1;
456 stats_n_bytes = len1;
457 stats_sw_if_index = sw_if_index1;
461 trace1:b1->
error = error1 ? node->
errors[error1] : 0;
473 n_left_to_next, bi0, bi1, next0,
477 while (n_left_from > 0 && n_left_to_next > 0)
482 ip4_vxlan_gpe_header_t *iuvn4_0;
483 ip6_vxlan_gpe_header_t *iuvn6_0;
487 vxlan4_gpe_tunnel_key_t key4_0;
488 vxlan6_gpe_tunnel_key_t key6_0;
490 u32 sw_if_index0, len0;
534 VXLAN_GPE_INPUT_NEXT_DROP;
536 key4_0.local = iuvn4_0->ip4.dst_address.as_u32;
537 key4_0.remote = iuvn4_0->ip4.src_address.as_u32;
538 key4_0.vni = iuvn4_0->vxlan.vni_res;
543 || (key4_0.as_u64[1] !=
544 last_key4.as_u64[1])))
550 error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
554 last_key4.as_u64[0] = key4_0.as_u64[0];
555 last_key4.as_u64[1] = key4_0.as_u64[1];
556 tunnel_index0 = last_tunnel_index = p0[0];
559 tunnel_index0 = last_tunnel_index;
566 VXLAN_GPE_INPUT_NEXT_DROP;
568 key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
569 key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
570 key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
571 key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
572 key6_0.vni = iuvn6_0->vxlan.vni_res;
576 (memcmp (&key6_0, &last_key6,
sizeof (last_key6)) != 0))
582 error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
586 memcpy (&last_key6, &key6_0,
sizeof (key6_0));
587 tunnel_index0 = last_tunnel_index = p0[0];
590 tunnel_index0 = last_tunnel_index;
611 stats_n_packets += 1;
612 stats_n_bytes += len0;
618 stats_n_packets -= 1;
619 stats_n_bytes -= len0;
628 stats_n_bytes = len0;
629 stats_sw_if_index = sw_if_index0;
632 trace00:b0->
error = error0 ? node->
errors[error0] : 0;
643 n_left_to_next, bi0, next0);
652 VXLAN_GPE_ERROR_DECAPSULATED,
660 thread_index, stats_sw_if_index,
661 stats_n_packets, stats_n_bytes);
685 #ifndef CLIB_MARCH_VARIANT 725 #define vxlan_gpe_error(n,s) s, 727 #undef vxlan_gpe_error 733 .name =
"vxlan4-gpe-input",
735 .vector_size =
sizeof (
u32),
742 #define _(s,n) [VXLAN_GPE_INPUT_NEXT_##s] = n, 755 .name =
"vxlan6-gpe-input",
757 .vector_size =
sizeof (
u32),
764 #define _(s,n) [VXLAN_GPE_INPUT_NEXT_##s] = n, 788 u32 *from, *to_next, n_left_from, n_left_to_next, next_index;
791 vtep4_key_t last_vtep4;
793 vtep6_key_t last_vtep6;
796 #ifdef CLIB_HAVE_VEC512 815 while (n_left_from > 0)
819 while (n_left_from >= 4 && n_left_to_next >= 2)
825 u32 bi0, ip_len0, udp_len0, flags0, next0;
826 u32 bi1, ip_len1, udp_len1, flags1, next1;
827 i32 len_diff0, len_diff1;
828 u8 error0, good_udp0, proto0;
829 u8 error1, good_udp1, proto1;
840 bi0 = to_next[0] = from[0];
841 bi1 = to_next[1] = from[1];
877 if (proto0 != IP_PROTOCOL_UDP)
885 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE))
891 #ifdef CLIB_HAVE_VEC512 893 (&ngm->
vtep_table, b0, ip40, &last_vtep4, &vtep4_u512))
906 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
913 ip_len0 = clib_net_to_host_u16 (ip40->
length);
916 udp_len0 = clib_net_to_host_u16 (udp0->
length);
917 len_diff0 = ip_len0 - udp_len0;
922 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
929 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
935 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
936 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
940 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
941 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
946 b0->
error = error0 ? error_node->
errors[error0] : 0;
960 if (proto1 != IP_PROTOCOL_UDP)
968 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE))
974 #ifdef CLIB_HAVE_VEC512 976 (&ngm->
vtep_table, b1, ip41, &last_vtep4, &vtep4_u512))
989 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
996 ip_len1 = clib_net_to_host_u16 (ip41->
length);
999 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1000 len_diff1 = ip_len1 - udp_len1;
1005 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1012 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1018 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1019 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1023 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1024 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1029 b1->
error = error1 ? error_node->
errors[error1] : 0;
1043 to_next, n_left_to_next,
1044 bi0, bi1, next0, next1);
1047 while (n_left_from > 0 && n_left_to_next > 0)
1053 u32 bi0, ip_len0, udp_len0, flags0, next0;
1055 u8 error0, good_udp0, proto0;
1057 bi0 = to_next[0] = from[0];
1061 n_left_to_next -= 1;
1078 if (proto0 != IP_PROTOCOL_UDP)
1086 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE))
1093 #ifdef CLIB_HAVE_VEC512 1095 (&ngm->
vtep_table, b0, ip40, &last_vtep4, &vtep4_u512))
1108 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1115 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1118 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1119 len_diff0 = ip_len0 - udp_len0;
1124 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1131 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1137 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1138 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1142 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1143 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1148 b0->
error = error0 ? error_node->
errors[error0] : 0;
1162 to_next, n_left_to_next,
1181 .name =
"ip4-vxlan-gpe-bypass",
1182 .vector_size =
sizeof (
u32),
1195 #ifndef CLIB_MARCH_VARIANT 1215 .name =
"ip6-vxlan-gpe-bypass",
1216 .vector_size =
sizeof (
u32),
1229 #ifndef CLIB_MARCH_VARIANT u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE 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.
u8 runtime_data[0]
Function dependent node-runtime data.
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
vnet_interface_main_t interface_main
Struct for VXLAN GPE decap packet tracing.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_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.
vnet_main_t * vnet_main
State convenience vnet_main_t.
static char * vxlan_gpe_error_strings[]
VXLAN GPE error strings.
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static void * ip4_next_header(ip4_header_t *i)
void vxlan_gpe_register_decap_protocol(u8 protocol_id, uword next_node_index)
static void vtep4_key_init(vtep4_key_t *k4)
vl_api_fib_path_type_t type
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 uword vxlan_gpe_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4)
Common processing for IPv4 and IPv6 VXLAN GPE decap dispatch functions.
Struct for VXLAN GPE tunnel.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vxlan_gpe_main_t vxlan_gpe_main
u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
#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).
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)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
clib_error_t * ip4_vxlan_gpe_bypass_init(vlib_main_t *vm)
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.
static void * ip6_next_header(ip6_header_t *i)
vlib_main_t vlib_node_runtime_t * node
#define foreach_vxlan_gpe_input_next
next nodes for VXLAN GPE input
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static u8 * format_vxlan_gpe_with_length(u8 *s, va_list *args)
Tracing function for VXLAN GPE packet decapsulation including length.
Struct for VXLAN GPE node state.
vlib_node_registration_t ip4_vxlan_gpe_bypass_node
(constructor) VLIB_REGISTER_NODE (ip4_vxlan_gpe_bypass_node)
static void vtep6_key_init(vtep6_key_t *k6)
clib_error_t * ip6_vxlan_gpe_bypass_init(vlib_main_t *vm)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX]
List of next nodes for the decap indexed on protocol.
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
void vxlan_gpe_unregister_decap_protocol(u8 protocol_id, uword next_node_index)
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
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.
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)
vlib_node_registration_t ip6_vxlan_gpe_bypass_node
(constructor) VLIB_REGISTER_NODE (ip6_vxlan_gpe_bypass_node)
#define hash_get_mem(h, key)
u32 sw_if_index
vnet intfc sw_if_index
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 u8 * format_vxlan_gpe_rx_trace(u8 *s, va_list *args)
Tracing function for VXLAN GPE packet decapsulation.
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)
static uword ip_vxlan_gpe_bypass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 is_ip4)
u8 * format_ip6_forward_next_trace(u8 *s, va_list *args)