39 "GENEVE decap from geneve_tunnel%d vni %d next %d error %d",
44 s =
format (s,
"GENEVE decap error - tunnel for vni %d does not exist",
74 u32 n_left_from, next_index, *from, *to_next;
78 u32 last_tunnel_index = ~0;
79 geneve4_tunnel_key_t last_key4;
80 geneve6_tunnel_key_t last_key6;
81 u32 pkts_decapsulated = 0;
83 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
87 last_key4.as_u64 = ~0;
97 stats_n_packets = stats_n_bytes = 0;
99 while (n_left_from > 0)
104 while (n_left_from >= 4 && n_left_to_next >= 2)
113 u32 tunnel_index0, tunnel_index1;
115 geneve4_tunnel_key_t key4_0, key4_1;
116 geneve6_tunnel_key_t key6_0, key6_1;
118 u32 sw_if_index0, sw_if_index1, len0, len1;
201 error0 = GENEVE_ERROR_BAD_FLAGS;
202 next0 = GENEVE_INPUT_NEXT_DROP;
205 #if SUPPORT_OPTIONS_HEADER==1 208 error0 = GENEVE_ERROR_BAD_FLAGS;
209 next0 = GENEVE_INPUT_NEXT_DROP;
224 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
225 next0 = GENEVE_INPUT_NEXT_DROP;
228 last_key4.as_u64 = key4_0.as_u64;
229 tunnel_index0 = last_tunnel_index = p0[0];
232 tunnel_index0 = last_tunnel_index;
238 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
239 next0 = GENEVE_INPUT_NEXT_DROP;
260 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
261 next0 = GENEVE_INPUT_NEXT_DROP;
267 key6_0.remote.as_u64[0] = ip6_0->
src_address.as_u64[0];
268 key6_0.remote.as_u64[1] = ip6_0->
src_address.as_u64[1];
273 (memcmp (&key6_0, &last_key6,
sizeof (last_key6)) != 0))
278 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
279 next0 = GENEVE_INPUT_NEXT_DROP;
283 tunnel_index0 = last_tunnel_index = p0[0];
286 tunnel_index0 = last_tunnel_index;
292 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
293 next0 = GENEVE_INPUT_NEXT_DROP;
304 key6_0.remote.as_u64[0] = ip6_0->
dst_address.as_u64[0];
305 key6_0.remote.as_u64[1] = ip6_0->
dst_address.as_u64[1];
314 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
315 next0 = GENEVE_INPUT_NEXT_DROP;
330 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
333 stats_n_packets += 1;
334 stats_n_bytes += len0;
340 stats_n_packets -= 1;
341 stats_n_bytes -= len0;
345 thread_index, stats_sw_if_index,
346 stats_n_packets, stats_n_bytes);
348 stats_n_bytes = len0;
349 stats_sw_if_index = sw_if_index0;
368 error1 = GENEVE_ERROR_BAD_FLAGS;
369 next1 = GENEVE_INPUT_NEXT_DROP;
372 #if SUPPORT_OPTIONS_HEADER==1 375 error1 = GENEVE_ERROR_BAD_FLAGS;
376 next1 = GENEVE_INPUT_NEXT_DROP;
391 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
392 next1 = GENEVE_INPUT_NEXT_DROP;
395 last_key4.as_u64 = key4_1.as_u64;
396 tunnel_index1 = last_tunnel_index = p1[0];
399 tunnel_index1 = last_tunnel_index;
405 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
406 next1 = GENEVE_INPUT_NEXT_DROP;
427 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
428 next1 = GENEVE_INPUT_NEXT_DROP;
434 key6_1.remote.as_u64[0] = ip6_1->
src_address.as_u64[0];
435 key6_1.remote.as_u64[1] = ip6_1->
src_address.as_u64[1];
440 (memcmp (&key6_1, &last_key6,
sizeof (last_key6)) != 0))
446 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
447 next1 = GENEVE_INPUT_NEXT_DROP;
452 tunnel_index1 = last_tunnel_index = p1[0];
455 tunnel_index1 = last_tunnel_index;
461 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
462 next1 = GENEVE_INPUT_NEXT_DROP;
473 key6_1.remote.as_u64[0] = ip6_1->
dst_address.as_u64[0];
474 key6_1.remote.as_u64[1] = ip6_1->
dst_address.as_u64[1];
483 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
484 next1 = GENEVE_INPUT_NEXT_DROP;
499 sw_if_index1 = (mt1) ? mt1->sw_if_index : sw_if_index1;
502 stats_n_packets += 1;
503 stats_n_bytes += len1;
509 stats_n_packets -= 1;
510 stats_n_bytes -= len1;
514 thread_index, stats_sw_if_index,
515 stats_n_packets, stats_n_bytes);
517 stats_n_bytes = len1;
518 stats_sw_if_index = sw_if_index1;
535 to_next, n_left_to_next,
536 bi0, bi1, next0, next1);
539 while (n_left_from > 0 && n_left_to_next > 0)
550 geneve4_tunnel_key_t key4_0;
551 geneve6_tunnel_key_t key6_0;
553 u32 sw_if_index0, len0;
606 error0 = GENEVE_ERROR_BAD_FLAGS;
607 next0 = GENEVE_INPUT_NEXT_DROP;
610 #if SUPPORT_OPTIONS_HEADER==1 613 error0 = GENEVE_ERROR_BAD_FLAGS;
614 next0 = GENEVE_INPUT_NEXT_DROP;
629 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
630 next0 = GENEVE_INPUT_NEXT_DROP;
633 last_key4.as_u64 = key4_0.as_u64;
634 tunnel_index0 = last_tunnel_index = p0[0];
637 tunnel_index0 = last_tunnel_index;
643 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
644 next0 = GENEVE_INPUT_NEXT_DROP;
665 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
666 next0 = GENEVE_INPUT_NEXT_DROP;
672 key6_0.remote.as_u64[0] = ip6_0->
src_address.as_u64[0];
673 key6_0.remote.as_u64[1] = ip6_0->
src_address.as_u64[1];
678 (memcmp (&key6_0, &last_key6,
sizeof (last_key6)) != 0))
683 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
684 next0 = GENEVE_INPUT_NEXT_DROP;
688 tunnel_index0 = last_tunnel_index = p0[0];
691 tunnel_index0 = last_tunnel_index;
697 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
698 next0 = GENEVE_INPUT_NEXT_DROP;
709 key6_0.remote.as_u64[0] = ip6_0->
dst_address.as_u64[0];
710 key6_0.remote.as_u64[1] = ip6_0->
dst_address.as_u64[1];
719 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
720 next0 = GENEVE_INPUT_NEXT_DROP;
735 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
738 stats_n_packets += 1;
739 stats_n_bytes += len0;
745 stats_n_packets -= 1;
746 stats_n_bytes -= len0;
750 thread_index, stats_sw_if_index,
751 stats_n_packets, stats_n_bytes);
753 stats_n_bytes = len0;
754 stats_sw_if_index = sw_if_index0;
770 to_next, n_left_to_next,
780 GENEVE_ERROR_DECAPSULATED, pkts_decapsulated);
787 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
809 #define geneve_error(n,s) s, 817 .name =
"geneve4-input",
819 .vector_size =
sizeof (
u32),
824 #define _(s,n) [GENEVE_INPUT_NEXT_##s] = n, 835 .name =
"geneve6-input",
837 .vector_size =
sizeof (
u32),
842 #define _(s,n) [GENEVE_INPUT_NEXT_##s] = n, 865 u32 *from, *to_next, n_left_from, n_left_to_next, next_index;
868 vtep4_key_t last_vtep4;
870 vtep6_key_t last_vtep6;
885 while (n_left_from > 0)
889 while (n_left_from >= 4 && n_left_to_next >= 2)
895 u32 bi0, ip_len0, udp_len0, flags0, next0;
896 u32 bi1, ip_len1, udp_len1, flags1, next1;
897 i32 len_diff0, len_diff1;
898 u8 error0, good_udp0, proto0;
899 u8 error1, good_udp1, proto1;
915 bi0 = to_next[0] = from[0];
916 bi1 = to_next[1] = from[1];
953 if (proto0 != IP_PROTOCOL_UDP)
961 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_geneve))
977 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
984 ip_len0 = clib_net_to_host_u16 (ip40->
length);
987 udp_len0 = clib_net_to_host_u16 (udp0->
length);
988 len_diff0 = ip_len0 - udp_len0;
993 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1000 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1006 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1007 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1011 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1012 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1017 b0->
error = error0 ? error_node->
errors[error0] : 0;
1031 if (proto1 != IP_PROTOCOL_UDP)
1039 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_geneve))
1055 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1062 ip_len1 = clib_net_to_host_u16 (ip41->
length);
1065 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1066 len_diff1 = ip_len1 - udp_len1;
1071 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1078 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1084 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1085 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1089 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1090 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1095 b1->
error = error1 ? error_node->
errors[error1] : 0;
1109 to_next, n_left_to_next,
1110 bi0, bi1, next0, next1);
1113 while (n_left_from > 0 && n_left_to_next > 0)
1119 u32 bi0, ip_len0, udp_len0, flags0, next0;
1121 u8 error0, good_udp0, proto0;
1123 bi0 = to_next[0] = from[0];
1127 n_left_to_next -= 1;
1145 if (proto0 != IP_PROTOCOL_UDP)
1153 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_geneve))
1169 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1176 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1179 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1180 len_diff0 = ip_len0 - udp_len0;
1185 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1192 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1198 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1199 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1203 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1204 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1209 b0->
error = error0 ? error_node->
errors[error0] : 0;
1223 to_next, n_left_to_next,
1243 .name =
"ip4-geneve-bypass",
1244 .vector_size =
sizeof (
u32),
1265 .name =
"ip6-geneve-bypass",
1266 .vector_size =
sizeof (
u32),
static u8 vnet_get_geneve_critical_bit(geneve_header_t *h)
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 u32 vnet_get_geneve_vni(geneve_header_t *h)
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
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
#define VLIB_NODE_FN(node)
static uword ip4_address_is_multicast(const ip4_address_t *a)
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 char * geneve_error_strings[]
#define GENEVE_BASE_HEADER_LENGTH
vlib_node_registration_t ip4_geneve_bypass_node
(constructor) VLIB_REGISTER_NODE (ip4_geneve_bypass_node)
geneve_tunnel_t * tunnels
static int ip4_is_fragment(const ip4_header_t *i)
static u8 vnet_get_geneve_options_len(geneve_header_t *h)
vl_api_interface_index_t sw_if_index
#define foreach_geneve_input_next
vlib_combined_counter_main_t * combined_sw_if_counters
static uword ip_geneve_bypass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 is_ip4)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static void * ip4_next_header(ip4_header_t *i)
static void vtep4_key_init(vtep4_key_t *k4)
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.
static void vnet_geneve_hdr_1word_ntoh(geneve_header_t *h)
vlib_node_registration_t ip4_input_node
Global ip4 input node.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u32 validate_geneve_fib(vlib_buffer_t *b, geneve_tunnel_t *t, u32 is_ip4)
u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
vlib_node_registration_t ip6_geneve_bypass_node
(constructor) VLIB_REGISTER_NODE (ip6_geneve_bypass_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.
#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)
vlib_node_registration_t geneve4_input_node
(constructor) VLIB_REGISTER_NODE (geneve4_input_node)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
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.
uword * geneve4_tunnel_by_key
vlib_main_t vlib_node_runtime_t * node
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.
static u8 * format_geneve_rx_trace(u8 *s, va_list *args)
static void vtep6_key_init(vtep6_key_t *k6)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static u8 vnet_get_geneve_version(geneve_header_t *h)
static uword ip6_address_is_equal(const ip6_address_t *a, const ip6_address_t *b)
static uword ip6_address_is_multicast(const ip6_address_t *a)
static u32 vnet_get_geneve_vni_network_order(geneve_header_t *h)
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.
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 buffer representation.
uword * geneve6_tunnel_by_key
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_registration_t geneve6_input_node
(constructor) VLIB_REGISTER_NODE (geneve6_input_node)
ip4_main_t ip4_main
Global ip4 main structure.
geneve_main_t geneve_main
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u16 flags
Copy of main node flags.
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
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 geneve_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u32 is_ip4)
u8 * format_ip6_forward_next_trace(u8 *s, va_list *args)