21 #define IP6_MAP_T_DUAL_LOOP 200 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
209 while (n_left_from > 0)
213 while (n_left_from > 0 && n_left_to_next > 0)
223 icmp46_header_t *icmp0;
225 pi0 = to_next[0] = from[0];
230 error0 = MAP_ERROR_NONE;
236 icmp0 = (icmp46_header_t *) (ip60 + 1);
250 error0 = MAP_ERROR_ICMP;
259 error0 = MAP_ERROR_ICMP;
276 map_t.map_domain_index, 1,
286 to_next, n_left_to_next, pi0,
309 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
316 while (n_left_from > 0)
320 #ifdef IP6_MAP_T_DUAL_LOOP 321 while (n_left_from >= 4 && n_left_to_next >= 2)
327 pi0 = to_next[0] = from[0];
328 pi1 = to_next[1] = from[1];
341 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
358 p1->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
374 to_next, n_left_to_next, pi0, pi1,
379 while (n_left_from > 0 && n_left_to_next > 0)
385 pi0 = to_next[0] = from[0];
396 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
412 to_next, n_left_to_next, pi0,
424 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
431 while (n_left_from > 0)
435 #ifdef IP6_MAP_T_DUAL_LOOP 436 while (n_left_from >= 4 && n_left_to_next >= 2)
442 pi0 = to_next[0] = from[0];
443 pi1 = to_next[1] = from[1];
489 n_left_to_next, pi0, pi1, next0,
494 while (n_left_from > 0 && n_left_to_next > 0)
500 pi0 = to_next[0] = from[0];
527 to_next, n_left_to_next, pi0,
539 u32 l4_len0, ip6_frag_hdr_t * frag0)
560 *error0 = (*map_port0 != -1) ? *error0 : MAP_ERROR_FRAGMENT_DROPPED;
565 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
568 l4_len0 <
sizeof (
tcp_header_t) ? MAP_ERROR_MALFORMED : *error0;
576 vnet_buffer (p0)->map_t.v6.l4_offset + port_offset));
580 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
583 l4_len0 <
sizeof (
udp_header_t) ? MAP_ERROR_MALFORMED : *error0;
591 vnet_buffer (p0)->map_t.v6.l4_offset + port_offset));
593 else if (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_ICMP6)
596 l4_len0 <
sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : *error0;
603 if (((icmp46_header_t *)
607 || ((icmp46_header_t *)
621 *error0 = MAP_ERROR_BAD_PROTOCOL;
628 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
638 while (n_left_from > 0)
642 #ifdef IP6_MAP_T_DUAL_LOOP 643 while (n_left_from >= 4 && n_left_to_next >= 2)
650 u32 l4_len0, l4_len1;
651 i32 map_port0, map_port1;
653 ip6_frag_hdr_t *frag0, *frag1;
656 pi0 = to_next[0] = from[0];
657 pi1 = to_next[1] = from[1];
663 error0 = MAP_ERROR_NONE;
664 error1 = MAP_ERROR_NONE;
743 error0 = MAP_ERROR_MALFORMED;
755 error1 = MAP_ERROR_MALFORMED;
759 map_port0 = map_port1 = -1;
761 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
763 sizeof (*ip60) -
vnet_buffer (p1)->map_t.v6.l4_offset;
785 (p0)->map_t.v6.saddr,
788 error0 = MAP_ERROR_SEC_CHECK;
798 (p1)->map_t.v6.saddr,
801 error1 = MAP_ERROR_SEC_CHECK;
811 && (error0 == MAP_ERROR_NONE))
828 && (error1 == MAP_ERROR_NONE))
844 map_t.map_domain_index, 1,
855 map_t.map_domain_index, 1,
865 n_left_to_next, pi0, pi1, next0,
870 while (n_left_from > 0 && n_left_to_next > 0)
879 ip6_frag_hdr_t *frag0;
883 pi0 = to_next[0] = from[0];
888 error0 = MAP_ERROR_NONE;
950 error0 = MAP_ERROR_MALFORMED;
956 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
967 error0 = (map_port0 != -1) ? error0 : MAP_ERROR_FRAGMENT_MEMORY;
972 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
989 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
1004 else if (
vnet_buffer (p0)->map_t.v6.l4_protocol ==
1009 sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : error0;
1011 if (((icmp46_header_t *)
1015 || ((icmp46_header_t *)
1018 l4_offset))->code == ICMP6_echo_request)
1028 error0 = MAP_ERROR_BAD_PROTOCOL;
1033 ((!mm->
is_ce) && (map_port0 != -1)
1039 (p0)->map_t.v6.saddr,
1043 error0 = MAP_ERROR_SEC_CHECK;
1054 && (error0 == MAP_ERROR_NONE))
1070 map_t.map_domain_index, 1,
1071 clib_net_to_host_u16
1078 to_next, n_left_to_next, pi0,
1087 #define _(sym,string) string, 1095 .name =
"ip6-map-t-fragmented",
1096 .vector_size =
sizeof (
u32),
1115 .name =
"ip6-map-t-icmp",
1116 .vector_size =
sizeof (
u32),
1135 .name =
"ip6-map-t-tcp-udp",
1136 .vector_size =
sizeof (
u32),
1155 .name =
"ip6-map-t",
1156 .vector_size =
sizeof(
u32),
#define map_ip4_reass_lock()
static uword ip6_map_t_tcp_udp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u16 ip6_get_port(ip6_header_t *ip6, u8 sender, u16 buffer_len)
Get TCP/UDP port number or ICMP id from IPv6 packet.
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 int icmp6_to_icmp(vlib_buffer_t *p, ip6_to_ip4_set_fn_t fn, void *ctx, ip6_to_ip4_set_fn_t inner_fn, void *inner_ctx)
Translate ICMP6 packet to ICMP4.
static uword ip6_map_t(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static int ip6_to_ip4_set_icmp_cb(ip6_header_t *ip6, ip4_header_t *ip4, void *arg)
vlib_error_t * errors
Vector of errors for this node.
struct _tcp_header tcp_header_t
static_always_inline void ip6_map_t_classify(vlib_buffer_t *p0, ip6_header_t *ip60, map_domain_t *d0, i32 *map_port0, u8 *error0, ip6_mapt_next_t *next0, u32 l4_len0, ip6_frag_hdr_t *frag0)
IPv4 to IPv6 translation.
static_always_inline u32 ip6_map_t_embedded_address(map_domain_t *d, ip6_address_t *addr)
#define static_always_inline
vlib_combined_counter_main_t * domain_counters
static_always_inline int ip6_parse(const ip6_header_t *ip6, u32 buff_len, u8 *l4_protocol, u16 *l4_offset, u16 *frag_hdr_offset)
Parse some useful information from IPv6 header.
static_always_inline i32 ip6_map_fragment_get(ip6_header_t *ip6, ip6_frag_hdr_t *frag, map_domain_t *d)
static int ip6_to_ip4_tcp_udp(vlib_buffer_t *p, ip6_to_ip4_set_fn_t fn, void *ctx, u8 udp_checksum)
Translate IPv6 UDP/TCP packet to IPv4.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
#define IP4_FRAG_NODE_NAME
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
static_always_inline map_domain_t * ip6_map_get_domain(u32 mdi, ip4_address_t *addr, u32 *map_domain_index, u8 *error)
vlib_node_registration_t ip6_map_t_tcp_udp_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_tcp_udp_node)
static_always_inline int ip6_map_fragment_cache(ip6_header_t *ip6, ip6_frag_hdr_t *frag, map_domain_t *d, u16 port)
static_always_inline u64 map_get_sfx_net(map_domain_t *d, u32 addr, u16 port)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
map_ip4_reass_t * map_ip4_reass_get(u32 src, u32 dst, u16 fragment_id, u8 protocol, u32 **pi_to_drop)
#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_error_t error
Error code for buffers to be enqueued to error handler.
vlib_node_registration_t ip6_map_t_fragmented_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_fragmented_node)
#define VLIB_REGISTER_NODE(x,...)
static uword ip6_map_t_icmp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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_always_inline u32 map_get_ip4(ip6_address_t *addr, map_domain_flags_e flags)
#define foreach_map_error
vlib_node_registration_t ip6_map_t_icmp_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_icmp_node)
static int ip6_to_ip4_set_inner_icmp_cb(ip6_header_t *ip6, ip4_header_t *ip4, void *arg)
#define ip6_frag_hdr_offset(hdr)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define map_ip4_reass_unlock()
u8 * format_map_trace(u8 *s, va_list *args)
IPv6 to IPv4 translation.
#define u8_ptr_add(ptr, index)
static int ip6_to_ip4_set_cb(ip6_header_t *ip6, ip4_header_t *ip4, void *ctx)
static uword ip6_map_t_fragmented(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
static char * map_t_error_strings[]
vlib_node_registration_t ip6_map_t_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_node)
ip6_mapt_fragmented_next_t
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static int ip6_to_ip4_fragmented(vlib_buffer_t *p, ip6_to_ip4_set_fn_t fn, void *ctx)
Translate IPv6 fragmented packet to IPv4.