25 #define foreach_vxlan_gbp_encap_error \ 26 _(ENCAPSULATED, "good packets encapsulated") 29 #define _(sym,string) string, 36 #define _(sym,str) VXLAN_GBP_ENCAP_ERROR_##sym, 62 s =
format (s,
"VXLAN_GBP encap to vxlan_gbp_tunnel%d vni %d sclass %d",
72 u32 n_left_from, next_index, *from, *to_next;
78 u32 pkts_encapsulated = 0;
80 u32 sw_if_index0 = 0, sw_if_index1 = 0;
81 u32 next0 = 0, next1 = 0;
93 u8 const underlay_hdr_len = is_ip4 ?
94 sizeof (ip4_vxlan_gbp_header_t) :
sizeof (ip6_vxlan_gbp_header_t);
95 u8 const rw_hdr_offset =
sizeof t0->rewrite_data - underlay_hdr_len;
97 u32 const csum_flags = is_ip4 ?
98 VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_IS_IP4 |
99 VNET_BUFFER_F_OFFLOAD_UDP_CKSUM : VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
101 while (n_left_from > 0)
107 while (n_left_from >= 4 && n_left_to_next >= 2)
123 u32 bi0 = to_next[0] = from[0];
124 u32 bi1 = to_next[1] = from[1];
152 sw_if_index1 = sw_if_index0;
155 dpoi_idx1 = dpoi_idx0;
165 dpoi_idx1 = t1->next_dpo.dpoi_index;
172 ASSERT (t0->rewrite_header.data_bytes == underlay_hdr_len);
173 ASSERT (t1->rewrite_header.data_bytes == underlay_hdr_len);
180 u16 payload_l0 = clib_host_to_net_u16 (len0 - l3_len);
181 u16 payload_l1 = clib_host_to_net_u16 (len1 - l3_len);
189 clib_memcpy (underlay0, t0->rewrite_header.data + rw_hdr_offset,
191 clib_memcpy (underlay1, t1->rewrite_header.data + rw_hdr_offset,
202 ip4_vxlan_gbp_header_t *hdr0 = underlay0;
203 ip4_vxlan_gbp_header_t *hdr1 = underlay1;
208 ip4_0->
length = clib_host_to_net_u16 (len0);
209 ip4_1->
length = clib_host_to_net_u16 (len1);
214 ip4_0->
tos = ip4_0_tos;
219 ip4_1->
tos = ip4_1_tos;
226 vxlan_gbp0 = &hdr0->vxlan_gbp;
227 vxlan_gbp1 = &hdr1->vxlan_gbp;
231 ip6_vxlan_gbp_header_t *hdr0 = underlay0;
232 ip6_vxlan_gbp_header_t *hdr1 = underlay1;
244 vxlan_gbp0 = &hdr0->vxlan_gbp;
245 vxlan_gbp1 = &hdr1->vxlan_gbp;
249 udp0->
length = payload_l0;
251 udp1->
length = payload_l1;
264 b0->
flags |= csum_flags;
267 b1->
flags |= csum_flags;
299 (vm, b0, ip6_0, &bogus);
304 (vm, b1, ip6_1, &bogus);
311 sw_if_index0, 1, len0);
313 sw_if_index1, 1, len1);
314 pkts_encapsulated += 2;
335 to_next, n_left_to_next,
336 bi0, bi1, next0, next1);
339 while (n_left_from > 0 && n_left_to_next > 0)
341 u32 bi0 = to_next[0] = from[0];
363 ASSERT (t0->rewrite_header.data_bytes == underlay_hdr_len);
371 clib_memcpy (underlay0, t0->rewrite_header.data + rw_hdr_offset,
375 u16 payload_l0 = clib_host_to_net_u16 (len0 - l3_len);
385 ip4_vxlan_gbp_header_t *hdr = underlay0;
389 ip4_0->
length = clib_host_to_net_u16 (len0);
394 ip4_0->
tos = ip4_0_tos;
399 vxlan_gbp0 = &hdr->vxlan_gbp;
403 ip6_vxlan_gbp_header_t *hdr = underlay0;
411 vxlan_gbp0 = &hdr->vxlan_gbp;
415 udp0->
length = payload_l0;
425 b0->
flags |= csum_flags;
448 (vm, b0, ip6_0, &bogus);
455 sw_if_index0, 1, len0);
467 to_next, n_left_to_next,
476 VXLAN_GBP_ENCAP_ERROR_ENCAPSULATED,
505 .name =
"vxlan4-gbp-encap",
506 .vector_size =
sizeof (
u32),
522 .name =
"vxlan6-gbp-encap",
523 .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.
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
static uword vxlan4_gbp_encap(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
vlib_node_registration_t vxlan4_gbp_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gbp_encap_node)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
vxlan_gbp_main_t vxlan_gbp_main
static uword vxlan_gbp_encap_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4, u8 csum_offload)
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.
vlib_node_registration_t vxlan6_gbp_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gbp_encap_node)
#define foreach_vxlan_gbp_encap_error
vlib_combined_counter_main_t * combined_sw_if_counters
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static char * vxlan_gbp_encap_error_strings[]
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).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
#define clib_memcpy(a, b, c)
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)
static uword vxlan6_gbp_encap(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
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 void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
index_t dpoi_index
the index of objects of that type
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
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)
A collection of combined counters.
vxlan_gbp_tunnel_t * tunnels
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.
#define STATIC_ASSERT_SIZEOF(d, s)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
u8 qos_bits_t
Type, er, safety for us water based entities.
static u16 ip_csum_fold(ip_csum_t c)
u8 * format_vxlan_gbp_encap_trace(u8 *s, va_list *args)