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;
251 map_t.map_domain_index, 1,
260 to_next, n_left_to_next, pi0,
271 ip4_mapt_pseudo_header_t *pheader =
ctx;
285 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
292 while (n_left_from > 0)
296 while (n_left_from > 0 && n_left_to_next > 0)
300 ip4_mapt_pseudo_header_t *pheader0;
301 ip4_mapt_fragmented_next_t next0;
304 pi0 = to_next[0] = from[0];
318 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
334 to_next, n_left_to_next, pi0,
346 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
354 while (n_left_from > 0)
358 #ifdef IP4_MAP_T_DUAL_LOOP 359 while (n_left_from >= 4 && n_left_to_next >= 2)
363 ip4_mapt_pseudo_header_t *pheader0, *pheader1;
364 ip4_mapt_tcp_udp_next_t next0, next1;
366 pi0 = to_next[0] = from[0];
367 pi1 = to_next[1] = from[1];
421 to_next, n_left_to_next, pi0, pi1,
426 while (n_left_from > 0 && n_left_to_next > 0)
430 ip4_mapt_pseudo_header_t *pheader0;
431 ip4_mapt_tcp_udp_next_t next0;
433 pi0 = to_next[0] = from[0];
464 to_next, n_left_to_next, pi0,
476 u8 * error0, ip4_mapt_next_t * next0)
496 *error0 = (*dst_port0 == -1) ? MAP_ERROR_FRAGMENT_MEMORY : *error0;
503 *error0 = ip4_len0 < 40 ? MAP_ERROR_MALFORMED : *error0;
511 *error0 = ip4_len0 < 28 ? MAP_ERROR_MALFORMED : *error0;
515 else if (ip40->
protocol == IP_PROTOCOL_ICMP)
520 else if (((icmp46_header_t *)
u8_ptr_add (ip40,
sizeof (*ip40)))->code
522 || ((icmp46_header_t *)
524 sizeof (*ip40)))->code == ICMP4_echo_request)
529 *error0 = MAP_ERROR_BAD_PROTOCOL;
536 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
546 while (n_left_from > 0)
550 #ifdef IP4_MAP_T_DUAL_LOOP 551 while (n_left_from >= 4 && n_left_to_next >= 2)
557 ip4_mapt_next_t next0 = 0, next1 = 0;
558 u16 ip4_len0, ip4_len1;
560 i32 map_port0, map_port1;
561 ip4_mapt_pseudo_header_t *pheader0, *pheader1;
563 pi0 = to_next[0] = from[0];
564 pi1 = to_next[1] = from[1];
569 error0 = MAP_ERROR_NONE;
570 error1 = MAP_ERROR_NONE;
576 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
577 ip4_len1 = clib_host_to_net_u16 (ip41->
length);
582 error0 = MAP_ERROR_UNKNOWN;
589 error1 = MAP_ERROR_UNKNOWN;
624 pheader0->saddr.as_u64[0] =
627 pheader0->saddr.as_u64[1] =
630 pheader1->saddr.as_u64[0] =
633 pheader1->saddr.as_u64[1] =
643 pheader0->daddr.as_u64[0] =
646 pheader0->daddr.as_u64[1] =
649 pheader1->daddr.as_u64[0] =
652 pheader1->daddr.as_u64[1] =
660 && ip4_map_fragment_cache (ip40, map_port0)))
662 error0 = MAP_ERROR_FRAGMENT_MEMORY;
668 && ip4_map_fragment_cache (ip41, map_port1)))
670 error1 = MAP_ERROR_FRAGMENT_MEMORY;
679 map_t.map_domain_index, 1,
690 map_t.map_domain_index, 1,
700 n_left_to_next, pi0, pi1, next0,
705 while (n_left_from > 0 && n_left_to_next > 0)
711 ip4_mapt_next_t next0;
715 ip4_mapt_pseudo_header_t *pheader0;
717 pi0 = to_next[0] = from[0];
722 error0 = MAP_ERROR_NONE;
726 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
730 error0 = MAP_ERROR_UNKNOWN;
753 pheader0->saddr.as_u64[0] =
756 pheader0->saddr.as_u64[1] =
764 pheader0->daddr.as_u64[0] =
767 pheader0->daddr.as_u64[1] =
778 && ip4_map_fragment_cache (ip40, map_port0)))
780 error0 = MAP_ERROR_UNKNOWN;
789 map_t.map_domain_index, 1,
797 to_next, n_left_to_next, pi0,
805 static char *map_t_error_strings[] = {
806 #define _(sym,string) string, 814 .name =
"ip4-map-t-fragmented",
815 .vector_size =
sizeof(
u32),
820 .error_strings = map_t_error_strings,
834 .name =
"ip4-map-t-icmp",
835 .vector_size =
sizeof(
u32),
840 .error_strings = map_t_error_strings,
854 .name =
"ip4-map-t-tcp-udp",
855 .vector_size =
sizeof(
u32),
860 .error_strings = map_t_error_strings,
875 .vector_size =
sizeof(
u32),
880 .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 int ip4_get_fragment_offset(ip4_header_t *i)
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_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_always_inline uword vlib_get_thread_index(void)
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.
static int ip4_is_first_fragment(ip4_header_t *i)
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_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.