40 s =
format (s,
"GTPU decap from gtpu_tunnel%d teid %d next %d error %d",
45 s =
format (s,
"GTPU decap error - tunnel for teid %d does not exist",
76 u32 n_left_from, next_index, * from, * to_next;
80 u32 last_tunnel_index = ~0;
81 gtpu4_tunnel_key_t last_key4;
82 gtpu6_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;
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)
113 u32 gtpu_hdr_len0 = 0, gtpu_hdr_len1 =0 ;
115 u32 tunnel_index0, tunnel_index1;
117 gtpu4_tunnel_key_t key4_0, key4_1;
118 gtpu6_tunnel_key_t key6_0, key6_1;
120 u32 sw_if_index0, sw_if_index1, len0, len1;
188 error0 = GTPU_ERROR_BAD_VER;
189 next0 = GTPU_INPUT_NEXT_DROP;
196 key4_0.teid = gtpu0->
teid;
205 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
206 next0 = GTPU_INPUT_NEXT_DROP;
209 last_key4.as_u64 = key4_0.as_u64;
210 tunnel_index0 = last_tunnel_index = p0[0];
213 tunnel_index0 = last_tunnel_index;
219 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
220 next0 = GTPU_INPUT_NEXT_DROP;
230 key4_0.teid = gtpu0->
teid;
239 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
240 next0 = GTPU_INPUT_NEXT_DROP;
246 key6_0.teid = gtpu0->
teid;
250 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
255 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
256 next0 = GTPU_INPUT_NEXT_DROP;
260 tunnel_index0 = last_tunnel_index = p0[0];
263 tunnel_index0 = last_tunnel_index;
269 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
270 next0 = GTPU_INPUT_NEXT_DROP;
282 key6_0.teid = gtpu0->
teid;
290 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
291 next0 = GTPU_INPUT_NEXT_DROP;
325 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
327 pkts_decapsulated ++;
328 stats_n_packets += 1;
329 stats_n_bytes += len0;
335 stats_n_packets -= 1;
336 stats_n_bytes -= len0;
340 thread_index, stats_sw_if_index,
341 stats_n_packets, stats_n_bytes);
343 stats_n_bytes = len0;
344 stats_sw_if_index = sw_if_index0;
357 tr->
teid = clib_net_to_host_u32(gtpu0->
teid);
362 error1 = GTPU_ERROR_BAD_VER;
363 next1 = GTPU_INPUT_NEXT_DROP;
370 key4_1.teid = gtpu1->
teid;
379 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
380 next1 = GTPU_INPUT_NEXT_DROP;
383 last_key4.as_u64 = key4_1.as_u64;
384 tunnel_index1 = last_tunnel_index = p1[0];
387 tunnel_index1 = last_tunnel_index;
393 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
394 next1 = GTPU_INPUT_NEXT_DROP;
404 key4_1.teid = gtpu1->
teid;
413 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
414 next1 = GTPU_INPUT_NEXT_DROP;
420 key6_1.teid = gtpu1->
teid;
424 if (
PREDICT_FALSE (memcmp(&key6_1, &last_key6,
sizeof(last_key6)) != 0))
430 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
431 next1 = GTPU_INPUT_NEXT_DROP;
436 tunnel_index1 = last_tunnel_index = p1[0];
439 tunnel_index1 = last_tunnel_index;
445 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
446 next1 = GTPU_INPUT_NEXT_DROP;
458 key6_1.teid = gtpu1->
teid;
466 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
467 next1 = GTPU_INPUT_NEXT_DROP;
501 sw_if_index1 = (mt1) ? mt1->sw_if_index : sw_if_index1;
503 pkts_decapsulated ++;
504 stats_n_packets += 1;
505 stats_n_bytes += len1;
511 stats_n_packets -= 1;
512 stats_n_bytes -= len1;
516 thread_index, stats_sw_if_index,
517 stats_n_packets, stats_n_bytes);
519 stats_n_bytes = len1;
520 stats_sw_if_index = sw_if_index1;
533 tr->
teid = clib_net_to_host_u32(gtpu1->
teid);
537 to_next, n_left_to_next,
538 bi0, bi1, next0, next1);
541 while (n_left_from > 0 && n_left_to_next > 0)
549 u32 gtpu_hdr_len0 = 0;
553 gtpu4_tunnel_key_t key4_0;
554 gtpu6_tunnel_key_t key6_0;
556 u32 sw_if_index0, len0;
592 error0 = GTPU_ERROR_BAD_VER;
593 next0 = GTPU_INPUT_NEXT_DROP;
599 key4_0.teid = gtpu0->
teid;
608 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
609 next0 = GTPU_INPUT_NEXT_DROP;
612 last_key4.as_u64 = key4_0.as_u64;
613 tunnel_index0 = last_tunnel_index = p0[0];
616 tunnel_index0 = last_tunnel_index;
622 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
623 next0 = GTPU_INPUT_NEXT_DROP;
633 key4_0.teid = gtpu0->
teid;
642 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
643 next0 = GTPU_INPUT_NEXT_DROP;
649 key6_0.teid = gtpu0->
teid;
653 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
658 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
659 next0 = GTPU_INPUT_NEXT_DROP;
663 tunnel_index0 = last_tunnel_index = p0[0];
666 tunnel_index0 = last_tunnel_index;
672 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
673 next0 = GTPU_INPUT_NEXT_DROP;
685 key6_0.teid = gtpu0->
teid;
693 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
694 next0 = GTPU_INPUT_NEXT_DROP;
728 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
730 pkts_decapsulated ++;
731 stats_n_packets += 1;
732 stats_n_bytes += len0;
738 stats_n_packets -= 1;
739 stats_n_bytes -= len0;
743 thread_index, stats_sw_if_index,
744 stats_n_packets, stats_n_bytes);
746 stats_n_bytes = len0;
747 stats_sw_if_index = sw_if_index0;
760 tr->
teid = clib_net_to_host_u32(gtpu0->
teid);
763 to_next, n_left_to_next,
772 GTPU_ERROR_DECAPSULATED,
780 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
804 #define gtpu_error(n,s) s, 812 .name =
"gtpu4-input",
814 .vector_size =
sizeof (
u32),
821 #define _(s,n) [GTPU_INPUT_NEXT_##s] = n, 835 .name =
"gtpu6-input",
837 .vector_size =
sizeof (
u32),
844 #define _(s,n) [GTPU_INPUT_NEXT_##s] = n, 870 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
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_GTPU))
985 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
992 ip_len0 = clib_net_to_host_u16 (ip40->
length);
995 udp_len0 = clib_net_to_host_u16 (udp0->
length);
996 len_diff0 = ip_len0 - udp_len0;
1001 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1008 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1014 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1015 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1019 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1020 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1025 b0->
error = error0 ? error_node->
errors[error0] : 0;
1035 if (proto1 != IP_PROTOCOL_UDP)
1043 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
1067 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1074 ip_len1 = clib_net_to_host_u16 (ip41->
length);
1077 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1078 len_diff1 = ip_len1 - udp_len1;
1083 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1090 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1096 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1097 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1101 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1102 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1107 b1->
error = error1 ? error_node->
errors[error1] : 0;
1117 to_next, n_left_to_next,
1118 bi0, bi1, next0, next1);
1121 while (n_left_from > 0 && n_left_to_next > 0)
1127 u32 bi0, ip_len0, udp_len0, flags0, next0;
1129 u8 error0, good_udp0, proto0;
1131 bi0 = to_next[0] = from[0];
1135 n_left_to_next -= 1;
1153 if (proto0 != IP_PROTOCOL_UDP)
1161 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
1185 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1192 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1195 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1196 len_diff0 = ip_len0 - udp_len0;
1201 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1208 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1214 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1215 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1219 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1220 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1225 b0->
error = error0 ? error_node->
errors[error0] : 0;
1235 to_next, n_left_to_next,
1255 .name =
"ip4-gtpu-bypass",
1256 .vector_size =
sizeof (
u32),
1286 .name =
"ip6-gtpu-bypass",
1287 .vector_size =
sizeof (
u32),
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.
static u8 * format_gtpu_rx_trace(u8 *s, va_list *args)
vnet_interface_main_t interface_main
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u32 validate_gtpu_fib(vlib_buffer_t *b, gtpu_tunnel_t *t, u32 is_ip4)
vlib_node_registration_t ip6_gtpu_bypass_node
(constructor) VLIB_REGISTER_NODE (ip6_gtpu_bypass_node)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
clib_error_t * ip6_gtpu_bypass_init(vlib_main_t *vm)
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 uword gtpu6_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static int ip4_is_fragment(const ip4_header_t *i)
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t ip4_gtpu_bypass_node
(constructor) VLIB_REGISTER_NODE (ip4_gtpu_bypass_node)
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)
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#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 void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static char * gtpu_error_strings[]
static uword ip_gtpu_bypass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 is_ip4)
static uword ip6_gtpu_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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).
vlib_node_registration_t gtpu4_input_node
(constructor) VLIB_REGISTER_NODE (gtpu4_input_node)
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)
clib_error_t * ip4_gtpu_bypass_init(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
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_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
static uword gtpu_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u32 is_ip4)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
static uword gtpu4_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
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)
#define foreach_gtpu_input_next
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
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)
uword * gtpu4_tunnel_by_key
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.
struct _vlib_node_registration vlib_node_registration_t
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)
uword * gtpu6_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)
ip4_main_t ip4_main
Global ip4 main structure.
u16 flags
Copy of main node flags.
static uword ip4_gtpu_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_NODE_FLAG_TRACE
#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.
u32 * fib_index_by_sw_if_index
vlib_node_registration_t gtpu6_input_node
(constructor) VLIB_REGISTER_NODE (gtpu6_input_node)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
u8 * format_ip6_forward_next_trace(u8 *s, va_list *args)