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;
277 map_t.map_domain_index, 1,
287 to_next, n_left_to_next, pi0,
310 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
317 while (n_left_from > 0)
321 #ifdef IP6_MAP_T_DUAL_LOOP 322 while (n_left_from >= 4 && n_left_to_next >= 2)
328 pi0 = to_next[0] = from[0];
329 pi1 = to_next[1] = from[1];
342 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
360 p1->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
377 to_next, n_left_to_next, pi0, pi1,
382 while (n_left_from > 0 && n_left_to_next > 0)
388 pi0 = to_next[0] = from[0];
399 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
416 to_next, n_left_to_next, pi0,
428 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
435 while (n_left_from > 0)
439 #ifdef IP6_MAP_T_DUAL_LOOP 440 while (n_left_from >= 4 && n_left_to_next >= 2)
446 pi0 = to_next[0] = from[0];
447 pi1 = to_next[1] = from[1];
495 n_left_to_next, pi0, pi1, next0,
500 while (n_left_from > 0 && n_left_to_next > 0)
506 pi0 = to_next[0] = from[0];
534 to_next, n_left_to_next, pi0,
546 u32 l4_len0, ip6_frag_hdr_t * frag0)
567 *error0 = (*map_port0 != -1) ? *error0 : MAP_ERROR_FRAGMENT_DROPPED;
572 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
575 l4_len0 <
sizeof (
tcp_header_t) ? MAP_ERROR_MALFORMED : *error0;
583 vnet_buffer (p0)->map_t.v6.l4_offset + port_offset));
587 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
590 l4_len0 <
sizeof (
udp_header_t) ? MAP_ERROR_MALFORMED : *error0;
598 vnet_buffer (p0)->map_t.v6.l4_offset + port_offset));
600 else if (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_ICMP6)
603 l4_len0 <
sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : *error0;
610 if (((icmp46_header_t *)
614 || ((icmp46_header_t *)
628 *error0 = MAP_ERROR_BAD_PROTOCOL;
635 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
645 while (n_left_from > 0)
649 #ifdef IP6_MAP_T_DUAL_LOOP 650 while (n_left_from >= 4 && n_left_to_next >= 2)
657 u32 l4_len0, l4_len1;
658 i32 map_port0, map_port1;
660 ip6_frag_hdr_t *frag0, *frag1;
663 pi0 = to_next[0] = from[0];
664 pi1 = to_next[1] = from[1];
670 error0 = MAP_ERROR_NONE;
671 error1 = MAP_ERROR_NONE;
750 error0 = MAP_ERROR_MALFORMED;
762 error1 = MAP_ERROR_MALFORMED;
766 map_port0 = map_port1 = -1;
768 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
770 sizeof (*ip60) -
vnet_buffer (p1)->map_t.v6.l4_offset;
792 (p0)->map_t.v6.saddr,
795 error0 = MAP_ERROR_SEC_CHECK;
805 (p1)->map_t.v6.saddr,
808 error1 = MAP_ERROR_SEC_CHECK;
818 && (error0 == MAP_ERROR_NONE))
835 && (error1 == MAP_ERROR_NONE))
851 map_t.map_domain_index, 1,
862 map_t.map_domain_index, 1,
872 n_left_to_next, pi0, pi1, next0,
877 while (n_left_from > 0 && n_left_to_next > 0)
886 ip6_frag_hdr_t *frag0;
890 pi0 = to_next[0] = from[0];
895 error0 = MAP_ERROR_NONE;
957 error0 = MAP_ERROR_MALFORMED;
963 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
974 error0 = (map_port0 != -1) ? error0 : MAP_ERROR_FRAGMENT_MEMORY;
979 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
996 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
1011 else if (
vnet_buffer (p0)->map_t.v6.l4_protocol ==
1016 sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : error0;
1018 if (((icmp46_header_t *)
1022 || ((icmp46_header_t *)
1025 l4_offset))->code == ICMP6_echo_request)
1035 error0 = MAP_ERROR_BAD_PROTOCOL;
1040 ((!mm->
is_ce) && (map_port0 != -1)
1046 (p0)->map_t.v6.saddr,
1050 error0 = MAP_ERROR_SEC_CHECK;
1061 && (error0 == MAP_ERROR_NONE))
1077 map_t.map_domain_index, 1,
1078 clib_net_to_host_u16
1085 to_next, n_left_to_next, pi0,
1094 #define _(sym,string) string, 1102 .name =
"ip6-map-t-fragmented",
1103 .vector_size =
sizeof (
u32),
1122 .name =
"ip6-map-t-icmp",
1123 .vector_size =
sizeof (
u32),
1142 .name =
"ip6-map-t-tcp-udp",
1143 .vector_size =
sizeof (
u32),
1162 .name =
"ip6-map-t",
1163 .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.