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, gtpu_hdr_len1;
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;
121 u8 has_space0, has_space1;
180 gtpu_hdr_len1 =
sizeof(
gtpu_header_t) - (((ver1 & GTPU_E_S_PN_BIT) == 0) * 4);
187 error0 = has_space0 ? GTPU_ERROR_BAD_VER : GTPU_ERROR_TOO_SMALL;
188 next0 = GTPU_INPUT_NEXT_DROP;
195 key4_0.teid = gtpu0->
teid;
204 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
205 next0 = GTPU_INPUT_NEXT_DROP;
208 last_key4.as_u64 = key4_0.as_u64;
209 tunnel_index0 = last_tunnel_index = p0[0];
212 tunnel_index0 = last_tunnel_index;
218 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
219 next0 = GTPU_INPUT_NEXT_DROP;
229 key4_0.teid = gtpu0->
teid;
238 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
239 next0 = GTPU_INPUT_NEXT_DROP;
245 key6_0.teid = gtpu0->
teid;
249 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
254 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
255 next0 = GTPU_INPUT_NEXT_DROP;
259 tunnel_index0 = last_tunnel_index = p0[0];
262 tunnel_index0 = last_tunnel_index;
268 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
269 next0 = GTPU_INPUT_NEXT_DROP;
281 key6_0.teid = gtpu0->
teid;
289 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
290 next0 = GTPU_INPUT_NEXT_DROP;
308 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
310 pkts_decapsulated ++;
311 stats_n_packets += 1;
312 stats_n_bytes += len0;
318 stats_n_packets -= 1;
319 stats_n_bytes -= len0;
323 thread_index, stats_sw_if_index,
324 stats_n_packets, stats_n_bytes);
326 stats_n_bytes = len0;
327 stats_sw_if_index = sw_if_index0;
340 tr->
teid = has_space0 ? clib_net_to_host_u32(gtpu0->
teid) : ~0;
345 error1 = has_space1 ? GTPU_ERROR_BAD_VER : GTPU_ERROR_TOO_SMALL;
346 next1 = GTPU_INPUT_NEXT_DROP;
353 key4_1.teid = gtpu1->
teid;
362 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
363 next1 = GTPU_INPUT_NEXT_DROP;
366 last_key4.as_u64 = key4_1.as_u64;
367 tunnel_index1 = last_tunnel_index = p1[0];
370 tunnel_index1 = last_tunnel_index;
376 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
377 next1 = GTPU_INPUT_NEXT_DROP;
387 key4_1.teid = gtpu1->
teid;
396 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
397 next1 = GTPU_INPUT_NEXT_DROP;
403 key6_1.teid = gtpu1->
teid;
407 if (
PREDICT_FALSE (memcmp(&key6_1, &last_key6,
sizeof(last_key6)) != 0))
413 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
414 next1 = GTPU_INPUT_NEXT_DROP;
419 tunnel_index1 = last_tunnel_index = p1[0];
422 tunnel_index1 = last_tunnel_index;
428 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
429 next1 = GTPU_INPUT_NEXT_DROP;
441 key6_1.teid = gtpu1->
teid;
449 error1 = GTPU_ERROR_NO_SUCH_TUNNEL;
450 next1 = GTPU_INPUT_NEXT_DROP;
468 sw_if_index1 = (mt1) ? mt1->sw_if_index : sw_if_index1;
470 pkts_decapsulated ++;
471 stats_n_packets += 1;
472 stats_n_bytes += len1;
478 stats_n_packets -= 1;
479 stats_n_bytes -= len1;
483 thread_index, stats_sw_if_index,
484 stats_n_packets, stats_n_bytes);
486 stats_n_bytes = len1;
487 stats_sw_if_index = sw_if_index1;
500 tr->
teid = has_space1 ? clib_net_to_host_u32(gtpu1->
teid) : ~0;
504 to_next, n_left_to_next,
505 bi0, bi1, next0, next1);
508 while (n_left_from > 0 && n_left_to_next > 0)
520 gtpu4_tunnel_key_t key4_0;
521 gtpu6_tunnel_key_t key6_0;
523 u32 sw_if_index0, len0;
561 error0 = has_space0 ? GTPU_ERROR_BAD_VER : GTPU_ERROR_TOO_SMALL;
562 next0 = GTPU_INPUT_NEXT_DROP;
568 key4_0.teid = gtpu0->
teid;
577 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
578 next0 = GTPU_INPUT_NEXT_DROP;
581 last_key4.as_u64 = key4_0.as_u64;
582 tunnel_index0 = last_tunnel_index = p0[0];
585 tunnel_index0 = last_tunnel_index;
591 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
592 next0 = GTPU_INPUT_NEXT_DROP;
602 key4_0.teid = gtpu0->
teid;
611 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
612 next0 = GTPU_INPUT_NEXT_DROP;
618 key6_0.teid = gtpu0->
teid;
622 if (
PREDICT_FALSE (memcmp(&key6_0, &last_key6,
sizeof(last_key6)) != 0))
627 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
628 next0 = GTPU_INPUT_NEXT_DROP;
632 tunnel_index0 = last_tunnel_index = p0[0];
635 tunnel_index0 = last_tunnel_index;
641 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
642 next0 = GTPU_INPUT_NEXT_DROP;
654 key6_0.teid = gtpu0->
teid;
662 error0 = GTPU_ERROR_NO_SUCH_TUNNEL;
663 next0 = GTPU_INPUT_NEXT_DROP;
681 sw_if_index0 = (mt0) ? mt0->
sw_if_index : sw_if_index0;
683 pkts_decapsulated ++;
684 stats_n_packets += 1;
685 stats_n_bytes += len0;
691 stats_n_packets -= 1;
692 stats_n_bytes -= len0;
696 thread_index, stats_sw_if_index,
697 stats_n_packets, stats_n_bytes);
699 stats_n_bytes = len0;
700 stats_sw_if_index = sw_if_index0;
713 tr->
teid = has_space0 ? clib_net_to_host_u32(gtpu0->
teid) : ~0;
716 to_next, n_left_to_next,
725 GTPU_ERROR_DECAPSULATED,
733 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
755 #define gtpu_error(n,s) s, 762 .name =
"gtpu4-input",
764 .vector_size =
sizeof (
u32),
771 #define _(s,n) [GTPU_INPUT_NEXT_##s] = n, 782 .name =
"gtpu6-input",
784 .vector_size =
sizeof (
u32),
791 #define _(s,n) [GTPU_INPUT_NEXT_##s] = n, 814 u32 * from, * to_next, n_left_from, n_left_to_next, next_index;
829 while (n_left_from > 0)
833 while (n_left_from >= 4 && n_left_to_next >= 2)
839 u32 bi0, ip_len0, udp_len0, flags0, next0;
840 u32 bi1, ip_len1, udp_len1, flags1, next1;
841 i32 len_diff0, len_diff1;
842 u8 error0, good_udp0, proto0;
843 u8 error1, good_udp1, proto1;
859 bi0 = to_next[0] = from[0];
860 bi1 = to_next[1] = from[1];
897 if (proto0 != IP_PROTOCOL_UDP)
905 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
929 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
936 ip_len0 = clib_net_to_host_u16 (ip40->
length);
939 udp_len0 = clib_net_to_host_u16 (udp0->
length);
940 len_diff0 = ip_len0 - udp_len0;
945 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
952 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
958 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
959 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
963 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
964 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
969 b0->
error = error0 ? error_node->
errors[error0] : 0;
979 if (proto1 != IP_PROTOCOL_UDP)
987 if (udp1->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
1011 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1018 ip_len1 = clib_net_to_host_u16 (ip41->
length);
1021 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1022 len_diff1 = ip_len1 - udp_len1;
1027 if ((flags1 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1034 (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1040 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1041 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
1045 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1046 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
1051 b1->
error = error1 ? error_node->
errors[error1] : 0;
1061 to_next, n_left_to_next,
1062 bi0, bi1, next0, next1);
1065 while (n_left_from > 0 && n_left_to_next > 0)
1071 u32 bi0, ip_len0, udp_len0, flags0, next0;
1073 u8 error0, good_udp0, proto0;
1075 bi0 = to_next[0] = from[0];
1079 n_left_to_next -= 1;
1097 if (proto0 != IP_PROTOCOL_UDP)
1105 if (udp0->
dst_port != clib_host_to_net_u16 (UDP_DST_PORT_GTPU))
1129 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1136 ip_len0 = clib_net_to_host_u16 (ip40->
length);
1139 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1140 len_diff0 = ip_len0 - udp_len0;
1145 if ((flags0 & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
1152 (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1158 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
1159 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
1163 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
1164 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
1169 b0->
error = error0 ? error_node->
errors[error0] : 0;
1179 to_next, n_left_to_next,
1197 .name =
"ip4-gtpu-bypass",
1198 .vector_size =
sizeof (
u32),
1210 #ifndef CLIB_MARCH_VARIANT 1226 .name =
"ip6-gtpu-bypass",
1227 .vector_size =
sizeof (
u32),
1239 #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)
vl_api_interface_index_t sw_if_index
#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.
vlib_main_t vlib_node_runtime_t * node
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
static u8 vlib_buffer_has_space(vlib_buffer_t *b, word l)
Check if there is enough space in buffer to advance.
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.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
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)