17 #include "../ip/ip_frag.h" 21 #define IP6_MAP_T_DUAL_LOOP 154 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
163 while (n_left_from > 0)
167 while (n_left_from > 0 && n_left_to_next > 0)
178 pi0 = to_next[0] = from[0];
183 error0 = MAP_ERROR_NONE;
199 error0 = MAP_ERROR_ICMP;
208 error0 = MAP_ERROR_ICMP;
226 map_t.map_domain_index, 1,
236 to_next, n_left_to_next, pi0,
259 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
266 while (n_left_from > 0)
270 #ifdef IP6_MAP_T_DUAL_LOOP 271 while (n_left_from >= 4 && n_left_to_next >= 2)
277 pi0 = to_next[0] = from[0];
278 pi1 = to_next[1] = from[1];
291 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
309 p1->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
326 to_next, n_left_to_next, pi0, pi1,
331 while (n_left_from > 0 && n_left_to_next > 0)
337 pi0 = to_next[0] = from[0];
348 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
365 to_next, n_left_to_next, pi0,
377 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
384 while (n_left_from > 0)
388 #ifdef IP6_MAP_T_DUAL_LOOP 389 while (n_left_from >= 4 && n_left_to_next >= 2)
395 pi0 = to_next[0] = from[0];
396 pi1 = to_next[1] = from[1];
444 n_left_to_next, pi0, pi1, next0,
449 while (n_left_from > 0 && n_left_to_next > 0)
455 pi0 = to_next[0] = from[0];
483 to_next, n_left_to_next, pi0,
495 u32 l4_len0, ip6_frag_hdr_t * frag0)
508 *error0 = (*src_port0 != -1) ? *error0 : MAP_ERROR_FRAGMENT_DROPPED;
513 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
516 l4_len0 <
sizeof (
tcp_header_t) ? MAP_ERROR_MALFORMED : *error0;
526 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
529 l4_len0 <
sizeof (
udp_header_t) ? MAP_ERROR_MALFORMED : *error0;
537 else if (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_ICMP6)
540 l4_len0 <
sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : *error0;
547 if (((icmp46_header_t *)
551 || ((icmp46_header_t *)
565 *error0 = MAP_ERROR_BAD_PROTOCOL;
572 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
581 while (n_left_from > 0)
585 #ifdef IP6_MAP_T_DUAL_LOOP 586 while (n_left_from >= 4 && n_left_to_next >= 2)
593 u32 l4_len0, l4_len1;
594 i32 src_port0, src_port1;
596 ip6_frag_hdr_t *frag0, *frag1;
600 pi0 = to_next[0] = from[0];
601 pi1 = to_next[1] = from[1];
607 error0 = MAP_ERROR_NONE;
608 error1 = MAP_ERROR_NONE;
644 error0 = MAP_ERROR_MALFORMED;
656 error1 = MAP_ERROR_MALFORMED;
660 src_port0 = src_port1 = -1;
662 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
664 sizeof (*ip60) -
vnet_buffer (p1)->map_t.v6.l4_offset;
686 (p0)->map_t.v6.saddr,
689 error0 = MAP_ERROR_SEC_CHECK;
699 (p1)->map_t.v6.saddr,
702 error1 = MAP_ERROR_SEC_CHECK;
712 && (error0 == MAP_ERROR_NONE))
729 && (error1 == MAP_ERROR_NONE))
745 map_t.map_domain_index, 1,
756 map_t.map_domain_index, 1,
766 n_left_to_next, pi0, pi1, next0,
771 while (n_left_from > 0 && n_left_to_next > 0)
780 ip6_frag_hdr_t *frag0;
784 pi0 = to_next[0] = from[0];
789 error0 = MAP_ERROR_NONE;
814 error0 = MAP_ERROR_MALFORMED;
820 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
831 error0 = (src_port0 != -1) ? error0 : MAP_ERROR_FRAGMENT_MEMORY;
836 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
851 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
869 sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : error0;
871 if (((icmp46_header_t *)
875 || ((icmp46_header_t *)
878 l4_offset))->code == ICMP6_echo_request)
888 error0 = MAP_ERROR_BAD_PROTOCOL;
899 (p0)->map_t.v6.saddr,
903 error0 = MAP_ERROR_SEC_CHECK;
914 && (error0 == MAP_ERROR_NONE))
930 map_t.map_domain_index, 1,
938 to_next, n_left_to_next, pi0,
947 #define _(sym,string) string, 955 .name =
"ip6-map-t-fragmented",
956 .vector_size =
sizeof (
u32),
975 .name =
"ip6-map-t-icmp",
976 .vector_size =
sizeof (
u32),
995 .name =
"ip6-map-t-tcp-udp",
996 .vector_size =
sizeof (
u32),
1015 .name =
"ip6-map-t",
1016 .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.
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 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
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)
static_always_inline uword vlib_get_thread_index(void)
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.
#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 u8_ptr_add(ptr, index)
#define map_ip4_reass_unlock()
u8 * format_map_trace(u8 *s, va_list *args)
IPv6 to IPv4 translation.
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_always_inline u32 map_get_ip4(ip6_address_t *addr)
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)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline void ip6_map_t_classify(vlib_buffer_t *p0, ip6_header_t *ip60, map_domain_t *d0, i32 *src_port0, u8 *error0, ip6_mapt_next_t *next0, u32 l4_len0, ip6_frag_hdr_t *frag0)
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.