20 #define IP4_MAP_T_DUAL_LOOP 1 64 }) ip4_mapt_pseudo_header_t;
77 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->
protocol,
95 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->
protocol,
173 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
182 while (n_left_from > 0)
186 while (n_left_from > 0 && n_left_to_next > 0)
190 ip4_mapt_icmp_next_t next0;
196 icmp46_header_t *icmp0;
199 pi0 = to_next[0] = from[0];
204 error0 = MAP_ERROR_NONE;
216 icmp0 = (icmp46_header_t *) (ip40 + 1);
225 error0 = MAP_ERROR_ICMP;
234 error0 = MAP_ERROR_ICMP;
250 map_t.map_domain_index, 1,
259 to_next, n_left_to_next, pi0,
270 ip4_mapt_pseudo_header_t *pheader =
ctx;
284 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
291 while (n_left_from > 0)
295 while (n_left_from > 0 && n_left_to_next > 0)
299 ip4_mapt_pseudo_header_t *pheader0;
300 ip4_mapt_fragmented_next_t next0;
303 pi0 = to_next[0] = from[0];
317 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
332 to_next, n_left_to_next, pi0,
344 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
352 while (n_left_from > 0)
356 #ifdef IP4_MAP_T_DUAL_LOOP 357 while (n_left_from >= 4 && n_left_to_next >= 2)
361 ip4_mapt_pseudo_header_t *pheader0, *pheader1;
362 ip4_mapt_tcp_udp_next_t next0, next1;
364 pi0 = to_next[0] = from[0];
365 pi1 = to_next[1] = from[1];
417 to_next, n_left_to_next, pi0, pi1,
422 while (n_left_from > 0 && n_left_to_next > 0)
426 ip4_mapt_pseudo_header_t *pheader0;
427 ip4_mapt_tcp_udp_next_t next0;
429 pi0 = to_next[0] = from[0];
459 to_next, n_left_to_next, pi0,
471 u8 * error0, ip4_mapt_next_t * next0)
491 *error0 = (*dst_port0 == -1) ? MAP_ERROR_FRAGMENT_MEMORY : *error0;
498 *error0 = ip4_len0 < 40 ? MAP_ERROR_MALFORMED : *error0;
506 *error0 = ip4_len0 < 28 ? MAP_ERROR_MALFORMED : *error0;
510 else if (ip40->
protocol == IP_PROTOCOL_ICMP)
515 else if (((icmp46_header_t *)
u8_ptr_add (ip40,
sizeof (*ip40)))->code
517 || ((icmp46_header_t *)
519 sizeof (*ip40)))->code == ICMP4_echo_request)
524 *error0 = MAP_ERROR_BAD_PROTOCOL;
531 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
541 while (n_left_from > 0)
545 #ifdef IP4_MAP_T_DUAL_LOOP 546 while (n_left_from >= 4 && n_left_to_next >= 2)
552 ip4_mapt_next_t next0 = 0, next1 = 0;
553 u16 ip4_len0, ip4_len1;
555 i32 map_port0, map_port1;
556 ip4_mapt_pseudo_header_t *pheader0, *pheader1;
558 pi0 = to_next[0] = from[0];
559 pi1 = to_next[1] = from[1];
564 error0 = MAP_ERROR_NONE;
565 error1 = MAP_ERROR_NONE;
571 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
572 ip4_len1 = clib_host_to_net_u16 (ip41->
length);
577 error0 = MAP_ERROR_UNKNOWN;
584 error1 = MAP_ERROR_UNKNOWN;
619 pheader0->saddr.as_u64[0] =
622 pheader0->saddr.as_u64[1] =
625 pheader1->saddr.as_u64[0] =
628 pheader1->saddr.as_u64[1] =
638 pheader0->daddr.as_u64[0] =
641 pheader0->daddr.as_u64[1] =
644 pheader1->daddr.as_u64[0] =
647 pheader1->daddr.as_u64[1] =
655 && ip4_map_fragment_cache (ip40, map_port0)))
657 error0 = MAP_ERROR_FRAGMENT_MEMORY;
663 && ip4_map_fragment_cache (ip41, map_port1)))
665 error1 = MAP_ERROR_FRAGMENT_MEMORY;
674 map_t.map_domain_index, 1,
685 map_t.map_domain_index, 1,
695 n_left_to_next, pi0, pi1, next0,
700 while (n_left_from > 0 && n_left_to_next > 0)
706 ip4_mapt_next_t next0;
710 ip4_mapt_pseudo_header_t *pheader0;
712 pi0 = to_next[0] = from[0];
717 error0 = MAP_ERROR_NONE;
721 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
725 error0 = MAP_ERROR_UNKNOWN;
741 && (clib_net_to_host_u16 (map_port0) <
744 error0 = MAP_ERROR_SEC_CHECK;
756 pheader0->saddr.as_u64[0] =
759 pheader0->saddr.as_u64[1] =
767 pheader0->daddr.as_u64[0] =
770 pheader0->daddr.as_u64[1] =
781 && ip4_map_fragment_cache (ip40, map_port0)))
783 error0 = MAP_ERROR_UNKNOWN;
792 map_t.map_domain_index, 1,
800 to_next, n_left_to_next, pi0,
808 static char *map_t_error_strings[] = {
809 #define _(sym,string) string, 817 .name =
"ip4-map-t-fragmented",
818 .vector_size =
sizeof(
u32),
823 .error_strings = map_t_error_strings,
837 .name =
"ip4-map-t-icmp",
838 .vector_size =
sizeof(
u32),
843 .error_strings = map_t_error_strings,
857 .name =
"ip4-map-t-tcp-udp",
858 .vector_size =
sizeof(
u32),
863 .error_strings = map_t_error_strings,
878 .vector_size =
sizeof(
u32),
883 .error_strings = map_t_error_strings,
#define map_ip4_reass_lock()
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.
#define IP6_FRAG_NODE_NAME
static_always_inline void ip4_map_t_classify(vlib_buffer_t *p0, map_domain_t *d0, ip4_header_t *ip40, u16 ip4_len0, i32 *dst_port0, u8 *error0, ip4_mapt_next_t *next0)
static_always_inline i32 ip4_map_fragment_get_port(ip4_header_t *ip4)
vlib_error_t * errors
Vector of errors for this node.
IPv4 to IPv6 translation.
static uword ip4_map_t_icmp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static int ip4_to_ip6_set_cb(ip4_header_t *ip4, ip6_header_t *ip6, void *ctx)
static uword ip4_map_t(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline void ip4_map_t_embedded_address(map_domain_t *d, ip6_address_t *ip6, const ip4_address_t *ip4)
#define static_always_inline
vlib_combined_counter_main_t * domain_counters
ip4_mapt_fragmented_next_t
static u16 ip4_get_port(ip4_header_t *ip, u8 sender)
Get TCP/UDP port number or ICMP id from IPv4 packet.
#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.
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
static int ip4_get_fragment_offset(const ip4_header_t *i)
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)
static_always_inline map_domain_t * ip4_map_get_domain(u32 mdi)
#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.
#define VLIB_REGISTER_NODE(x,...)
static int ip4_to_ip6_tcp_udp(vlib_buffer_t *p, ip4_to_ip6_set_fn_t fn, void *ctx)
Translate IPv4 UDP/TCP packet to IPv6.
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.
#define foreach_map_error
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static int ip4_to_ip6_set_inner_icmp_cb(ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
static int icmp_to_icmp6(vlib_buffer_t *p, ip4_to_ip6_set_fn_t fn, void *ctx, ip4_to_ip6_set_fn_t inner_fn, void *inner_ctx)
Translate ICMP4 packet to ICMP6.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define map_ip4_reass_unlock()
u8 * format_map_trace(u8 *s, va_list *args)
#define u8_ptr_add(ptr, index)
static int ip4_is_first_fragment(const ip4_header_t *i)
static int ip4_to_ip6_set_icmp_cb(ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
static uword ip4_map_t_tcp_udp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword ip4_map_t_fragmented(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static int ip4_to_ip6_fragmented(vlib_buffer_t *p, ip4_to_ip6_set_fn_t fn, void *ctx)
Translate IPv4 fragmented packet to IPv6.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
typedef CLIB_PACKED(struct{ip6_address_t daddr;ip6_address_t saddr;u8 unused[28];})
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.