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);
802 #define gtpu_error(n,s) s, 809 .name =
"gtpu4-input",
811 .vector_size =
sizeof (
u32),
818 #define _(s,n) [GTPU_INPUT_NEXT_##s] = n, 829 .name =
"gtpu6-input",
831 .vector_size =
sizeof (
u32),
838 #define _(s,n) [GTPU_INPUT_NEXT_##s] = n, 861 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
876 while (n_left_from > 0)
880 while (n_left_from >= 4 && n_left_to_next >= 2)
886 u32 bi0, ip_len0, udp_len0, flags0, next0;
887 u32 bi1, ip_len1, udp_len1, flags1, next1;
888 i32 len_diff0, len_diff1;
889 u8 error0, good_udp0, proto0;
890 u8 error1, good_udp1, proto1;
906 bi0 = to_next[0] = from[0];
907 bi1 = to_next[1] = from[1];
944 if (proto0 != IP_PROTOCOL_UDP)
952 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
976 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
983 ip_len0 = clib_net_to_host_u16 (ip40->
length);
986 udp_len0 = clib_net_to_host_u16 (udp0->
length);
987 len_diff0 = ip_len0 - udp_len0;
992 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
999 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1005 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1006 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1010 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1011 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1016 b0->
error = error0 ? error_node->
errors[error0] : 0;
1026 if (proto1 != IP_PROTOCOL_UDP)
1034 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
1058 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1065 ip_len1 = clib_net_to_host_u16 (ip41->
length);
1068 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1069 len_diff1 = ip_len1 - udp_len1;
1074 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1081 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1087 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1088 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1092 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1093 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1098 b1->
error = error1 ? error_node->
errors[error1] : 0;
1108 to_next, n_left_to_next,
1109 bi0, bi1, next0, next1);
1112 while (n_left_from > 0 && n_left_to_next > 0)
1118 u32 bi0, ip_len0, udp_len0, flags0, next0;
1120 u8 error0, good_udp0, proto0;
1122 bi0 = to_next[0] = from[0];
1126 n_left_to_next -= 1;
1144 if (proto0 != IP_PROTOCOL_UDP)
1152 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
1176 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1183 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1186 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1187 len_diff0 = ip_len0 - udp_len0;
1192 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1199 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1205 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1206 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1210 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1211 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1216 b0->
error = error0 ? error_node->
errors[error0] : 0;
1226 to_next, n_left_to_next,
1244 .name =
"ip4-gtpu-bypass",
1245 .vector_size =
sizeof (
u32),
1257 #ifndef CLIB_MARCH_VARIANT 1273 .name =
"ip6-gtpu-bypass",
1274 .vector_size =
sizeof (
u32),
1286 #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.
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)
#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 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)
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 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)
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)
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.
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
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)
#define hash_get_mem(h, key)
ip4_main_t ip4_main
Global ip4 main structure.
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
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)