23 #define foreach_vxlan_encap_error \ 24 _(ENCAPSULATED, "good packets encapsulated") 27 #define _(sym,string) string, 33 #define _(sym,str) VXLAN_ENCAP_ERROR_##sym, 56 s =
format (s,
"VXLAN encap to vxlan_tunnel%d vni %d",
62 #define foreach_fixed_header4_offset \ 65 #define foreach_fixed_header6_offset \ 66 _(0) _(1) _(2) _(3) _(4) _(5) _(6) 72 u8 is_ip4,
u8 csum_offload)
74 u32 n_left_from, next_index, * from, * to_next;
78 u32 pkts_encapsulated = 0;
79 u16 old_l0 = 0, old_l1 = 0;
81 u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
82 u32 sw_if_index0 = 0, sw_if_index1 = 0;
83 u32 next0 = 0, next1 = 0;
92 stats_n_packets = stats_n_bytes = 0;
94 while (n_left_from > 0)
99 to_next, n_left_to_next);
101 while (n_left_from >= 4 && n_left_to_next >= 2)
105 u32 flow_hash0, flow_hash1;
110 u64 * copy_src0, * copy_dst0;
111 u64 * copy_src1, * copy_dst1;
112 u32 * copy_src_last0, * copy_dst_last0;
113 u32 * copy_src_last1, * copy_dst_last1;
158 if (sw_if_index1 !=
vnet_buffer(b1)->sw_if_index[VLIB_TX])
175 ASSERT(
sizeof(ip4_vxlan_header_t) == 36);
183 copy_dst0 = (
u64 *) ip4_0;
185 copy_dst1 = (
u64 *) ip4_1;
186 copy_src1 = (
u64 *) t1->rewrite;
188 #define _(offs) copy_dst0[offs] = copy_src0[offs];
191 #define _(offs) copy_dst1[offs] = copy_src1[offs]; 195 copy_dst_last0 = (
u32 *)(©_dst0[4]);
196 copy_src_last0 = (
u32 *)(©_src0[4]);
197 copy_dst_last0[0] = copy_src_last0[0];
198 copy_dst_last1 = (
u32 *)(©_dst1[4]);
199 copy_src_last1 = (
u32 *)(©_src1[4]);
200 copy_dst_last1[0] = copy_src_last1[0];
205 ip4_0->
length = clib_host_to_net_u16
208 VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_IS_IP4;
210 ip4_1->
length = clib_host_to_net_u16
213 VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_IS_IP4;
249 b0->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
251 b1->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
260 ASSERT(
sizeof(ip6_vxlan_header_t) == 56);
267 copy_dst0 = (
u64 *) ip6_0;
269 copy_dst1 = (
u64 *) ip6_1;
270 copy_src1 = (
u64 *) t1->rewrite;
272 #define _(offs) copy_dst0[offs] = copy_src0[offs];
275 #define _(offs) copy_dst1[offs] = copy_src1[offs]; 299 b0->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
302 b1->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
309 (vm, b0, ip6_0, &bogus);
314 (vm, b1, ip6_1, &bogus);
321 pkts_encapsulated += 2;
324 stats_n_packets += 2;
325 stats_n_bytes += len0 + len1;
332 (sw_if_index1 != stats_sw_if_index)))
334 stats_n_packets -= 2;
335 stats_n_bytes -= len0 + len1;
336 if (sw_if_index0 == sw_if_index1)
341 thread_index, stats_sw_if_index,
342 stats_n_packets, stats_n_bytes);
343 stats_sw_if_index = sw_if_index0;
345 stats_n_bytes = len0 + len1;
351 thread_index, sw_if_index0, 1, len0);
354 thread_index, sw_if_index1, 1, len1);
375 to_next, n_left_to_next,
376 bi0, bi1, next0, next1);
379 while (n_left_from > 0 && n_left_to_next > 0)
388 u64 * copy_src0, * copy_dst0;
389 u32 * copy_src_last0, * copy_dst_last0;
421 ASSERT(
sizeof(ip4_vxlan_header_t) == 36);
426 copy_dst0 = (
u64 *) ip4_0;
429 #define _(offs) copy_dst0[offs] = copy_src0[offs];
433 copy_dst_last0 = (
u32 *)(©_dst0[4]);
434 copy_src_last0 = (
u32 *)(©_src0[4]);
435 copy_dst_last0[0] = copy_src_last0[0];
443 VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_IS_IP4;
467 b0->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
477 ASSERT(
sizeof(ip6_vxlan_header_t) == 56);
481 copy_dst0 = (
u64 *) ip6_0;
484 #define _(offs) copy_dst0[offs] = copy_src0[offs];
501 b0->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
508 (vm, b0, ip6_0, &bogus);
515 pkts_encapsulated ++;
517 stats_n_packets += 1;
518 stats_n_bytes += len0;
526 stats_n_packets -= 1;
527 stats_n_bytes -= len0;
531 thread_index, stats_sw_if_index,
532 stats_n_packets, stats_n_bytes);
534 stats_n_bytes = len0;
535 stats_sw_if_index = sw_if_index0;
546 to_next, n_left_to_next,
555 VXLAN_ENCAP_ERROR_ENCAPSULATED,
563 thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
593 .name =
"vxlan4-encap",
594 .vector_size =
sizeof (
u32),
609 .name =
"vxlan6-encap",
610 .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 vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
#define foreach_vxlan_encap_error
VLIB_NODE_FUNCTION_MULTIARCH(l2t_encap_node, l2t_encap_node_fn)
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 * vxlan_encap_error_strings[]
vlib_combined_counter_main_t * combined_sw_if_counters
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define foreach_fixed_header4_offset
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 node_index
Node index.
#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).
u8 * format_vxlan_encap_trace(u8 *s, va_list *args)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
#define VLIB_BUFFER_IS_TRACED
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.
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define foreach_fixed_header6_offset
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static uword vxlan_encap_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4, u8 csum_offload)
index_t dpoi_index
the index of objects of that type
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword vxlan6_encap(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
vlib_node_registration_t vxlan4_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan4_encap_node)
#define VLIB_REGISTER_NODE(x,...)
vlib_node_registration_t vxlan6_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan6_encap_node)
u16 dpoi_next_node
The next VLIB node to follow.
#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.
static uword vxlan4_encap(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip_csum_fold(ip_csum_t c)