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;
86 last_key4.as_u64 = ~0;
95 stats_n_packets = stats_n_bytes = 0;
97 while (n_left_from > 0)
102 while (n_left_from >= 4 && n_left_to_next >= 2)
111 u32 tunnel_index0, tunnel_index1;
113 geneve4_tunnel_key_t key4_0, key4_1;
114 geneve6_tunnel_key_t key6_0, key6_1;
116 u32 sw_if_index0, sw_if_index1, len0, len1;
205 error0 = GENEVE_ERROR_BAD_FLAGS;
206 next0 = GENEVE_INPUT_NEXT_DROP;
209 #if SUPPORT_OPTIONS_HEADER==1 212 error0 = GENEVE_ERROR_BAD_FLAGS;
213 next0 = GENEVE_INPUT_NEXT_DROP;
228 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
229 next0 = GENEVE_INPUT_NEXT_DROP;
232 last_key4.as_u64 = key4_0.as_u64;
233 tunnel_index0 = last_tunnel_index = p0[0];
236 tunnel_index0 = last_tunnel_index;
242 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
243 next0 = GENEVE_INPUT_NEXT_DROP;
264 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
265 next0 = GENEVE_INPUT_NEXT_DROP;
277 (memcmp (&key6_0, &last_key6,
sizeof (last_key6)) != 0))
282 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
283 next0 = GENEVE_INPUT_NEXT_DROP;
287 tunnel_index0 = last_tunnel_index = p0[0];
290 tunnel_index0 = last_tunnel_index;
296 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
297 next0 = GENEVE_INPUT_NEXT_DROP;
318 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
319 next0 = GENEVE_INPUT_NEXT_DROP;
334 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
337 stats_n_packets += 1;
338 stats_n_bytes += len0;
344 stats_n_packets -= 1;
345 stats_n_bytes -= len0;
349 thread_index, stats_sw_if_index,
350 stats_n_packets, stats_n_bytes);
352 stats_n_bytes = len0;
353 stats_sw_if_index = sw_if_index0;
372 error1 = GENEVE_ERROR_BAD_FLAGS;
373 next1 = GENEVE_INPUT_NEXT_DROP;
376 #if SUPPORT_OPTIONS_HEADER==1 379 error1 = GENEVE_ERROR_BAD_FLAGS;
380 next1 = GENEVE_INPUT_NEXT_DROP;
395 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
396 next1 = GENEVE_INPUT_NEXT_DROP;
399 last_key4.as_u64 = key4_1.as_u64;
400 tunnel_index1 = last_tunnel_index = p1[0];
403 tunnel_index1 = last_tunnel_index;
409 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
410 next1 = GENEVE_INPUT_NEXT_DROP;
431 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
432 next1 = GENEVE_INPUT_NEXT_DROP;
444 (memcmp (&key6_1, &last_key6,
sizeof (last_key6)) != 0))
450 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
451 next1 = GENEVE_INPUT_NEXT_DROP;
456 tunnel_index1 = last_tunnel_index = p1[0];
459 tunnel_index1 = last_tunnel_index;
465 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
466 next1 = GENEVE_INPUT_NEXT_DROP;
487 error1 = GENEVE_ERROR_NO_SUCH_TUNNEL;
488 next1 = GENEVE_INPUT_NEXT_DROP;
503 sw_if_index1 = (mt1) ? mt1->sw_if_index : sw_if_index1;
506 stats_n_packets += 1;
507 stats_n_bytes += len1;
513 stats_n_packets -= 1;
514 stats_n_bytes -= len1;
518 thread_index, stats_sw_if_index,
519 stats_n_packets, stats_n_bytes);
521 stats_n_bytes = len1;
522 stats_sw_if_index = sw_if_index1;
539 to_next, n_left_to_next,
540 bi0, bi1, next0, next1);
543 while (n_left_from > 0 && n_left_to_next > 0)
554 geneve4_tunnel_key_t key4_0;
555 geneve6_tunnel_key_t key6_0;
557 u32 sw_if_index0, len0;
609 error0 = GENEVE_ERROR_BAD_FLAGS;
610 next0 = GENEVE_INPUT_NEXT_DROP;
613 #if SUPPORT_OPTIONS_HEADER==1 616 error0 = GENEVE_ERROR_BAD_FLAGS;
617 next0 = GENEVE_INPUT_NEXT_DROP;
632 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
633 next0 = GENEVE_INPUT_NEXT_DROP;
636 last_key4.as_u64 = key4_0.as_u64;
637 tunnel_index0 = last_tunnel_index = p0[0];
640 tunnel_index0 = last_tunnel_index;
646 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
647 next0 = GENEVE_INPUT_NEXT_DROP;
668 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
669 next0 = GENEVE_INPUT_NEXT_DROP;
681 (memcmp (&key6_0, &last_key6,
sizeof (last_key6)) != 0))
686 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
687 next0 = GENEVE_INPUT_NEXT_DROP;
691 tunnel_index0 = last_tunnel_index = p0[0];
694 tunnel_index0 = last_tunnel_index;
700 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
701 next0 = GENEVE_INPUT_NEXT_DROP;
722 error0 = GENEVE_ERROR_NO_SUCH_TUNNEL;
723 next0 = GENEVE_INPUT_NEXT_DROP;
738 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
741 stats_n_packets += 1;
742 stats_n_bytes += len0;
748 stats_n_packets -= 1;
749 stats_n_bytes -= len0;
753 thread_index, stats_sw_if_index,
754 stats_n_packets, stats_n_bytes);
756 stats_n_bytes = len0;
757 stats_sw_if_index = sw_if_index0;
773 to_next, n_left_to_next,
783 GENEVE_ERROR_DECAPSULATED, pkts_decapsulated);
790 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
812 #define geneve_error(n,s) s, 820 .name =
"geneve4-input",
822 .vector_size =
sizeof (
u32),
827 #define _(s,n) [GENEVE_INPUT_NEXT_##s] = n, 838 .name =
"geneve6-input",
840 .vector_size =
sizeof (
u32),
845 #define _(s,n) [GENEVE_INPUT_NEXT_##s] = n, 868 u32 *from, *to_next, n_left_from, n_left_to_next, next_index;
886 while (n_left_from > 0)
890 while (n_left_from >= 4 && n_left_to_next >= 2)
896 u32 bi0, ip_len0, udp_len0, flags0, next0;
897 u32 bi1, ip_len1, udp_len1, flags1, next1;
898 i32 len_diff0, len_diff1;
899 u8 error0, good_udp0, proto0;
900 u8 error1, good_udp1, proto1;
916 bi0 = to_next[0] = from[0];
917 bi1 = to_next[1] = from[1];
954 if (proto0 != IP_PROTOCOL_UDP)
962 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_geneve))
986 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
993 ip_len0 = clib_net_to_host_u16 (ip40->
length);
996 udp_len0 = clib_net_to_host_u16 (udp0->
length);
997 len_diff0 = ip_len0 - udp_len0;
1002 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1009 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1015 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1016 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1020 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1021 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1026 b0->
error = error0 ? error_node->
errors[error0] : 0;
1040 if (proto1 != IP_PROTOCOL_UDP)
1048 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_geneve))
1072 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1079 ip_len1 = clib_net_to_host_u16 (ip41->
length);
1082 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1083 len_diff1 = ip_len1 - udp_len1;
1088 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1095 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1101 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1102 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1106 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1107 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1112 b1->
error = error1 ? error_node->
errors[error1] : 0;
1126 to_next, n_left_to_next,
1127 bi0, bi1, next0, next1);
1130 while (n_left_from > 0 && n_left_to_next > 0)
1136 u32 bi0, ip_len0, udp_len0, flags0, next0;
1138 u8 error0, good_udp0, proto0;
1140 bi0 = to_next[0] = from[0];
1144 n_left_to_next -= 1;
1162 if (proto0 != IP_PROTOCOL_UDP)
1170 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_geneve))
1194 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1201 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1204 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1205 len_diff0 = ip_len0 - udp_len0;
1210 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1217 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1223 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1224 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1228 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1229 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1234 b0->
error = error0 ? error_node->
errors[error0] : 0;
1248 to_next, n_left_to_next,
1268 .name =
"ip4-geneve-bypass",.vector_size =
1276 #ifndef CLIB_MARCH_VARIANT 1297 .name =
"ip6-geneve-bypass",.vector_size =
1306 #ifndef CLIB_MARCH_VARIANT 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)
#define VLIB_INIT_FUNCTION(x)
#define foreach_geneve_input_next
static u32 vnet_get_geneve_vni_bigendian(geneve_header_t *h)
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)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
clib_error_t * ip6_geneve_bypass_init(vlib_main_t *vm)
#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 void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
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 void ip6_address_set_zero(ip6_address_t *a)
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
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 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 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
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
clib_error_t * ip4_geneve_bypass_init(vlib_main_t *vm)
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)