65 }) ip4_mapt_pseudo_header_t;
78 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->
protocol,
96 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->
protocol,
144 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
153 while (n_left_from > 0)
157 while (n_left_from > 0 && n_left_to_next > 0)
161 ip4_mapt_icmp_next_t next0;
169 pi0 = to_next[0] = from[0];
174 error0 = MAP_ERROR_NONE;
193 error0 = MAP_ERROR_ICMP;
202 error0 = MAP_ERROR_ICMP;
223 map_t.map_domain_index, 1,
232 to_next, n_left_to_next, pi0,
245 ip4_mapt_pseudo_header_t * pheader)
249 ip6_frag_hdr_t *frag;
252 frag = (ip6_frag_hdr_t *)
u8_ptr_add (ip4,
sizeof (*ip4) -
sizeof (*frag));
255 sizeof (*ip4) -
sizeof (*frag) -
265 frag->fragment_offset_and_more =
272 clib_host_to_net_u32 ((6 << 28) + (ip4->
tos << 20));
274 clib_host_to_net_u16 (clib_net_to_host_u16 (ip4->
length) -
275 sizeof (*ip4) +
sizeof (*frag));
277 ip6->
protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
291 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
298 while (n_left_from > 0)
302 while (n_left_from > 0 && n_left_to_next > 0)
306 ip4_mapt_pseudo_header_t *pheader0;
307 ip4_mapt_fragmented_next_t next0;
310 pi0 = to_next[0] = from[0];
324 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
344 to_next, n_left_to_next, pi0,
363 ip6_frag_hdr_t *frag;
369 if (ip4->
protocol == IP_PROTOCOL_UDP)
381 u16 udp_len = clib_host_to_net_u16 (ip4->
length) -
sizeof (*ip4);
395 csum = tcp->checksum;
399 checksum = &tcp->checksum;
411 sizeof (*ip4) -
sizeof (*ip6) -
414 (ip6_frag_hdr_t *)
u8_ptr_add (ip4,
sizeof (*ip4) -
sizeof (*frag));
420 ip6 = (
ip6_header_t *) (((
u8 *) ip4) +
sizeof (*ip4) -
sizeof (*ip6));
426 clib_host_to_net_u32 ((6 << 28) + (ip4->
tos << 20));
433 frag->identification = frag_id;
436 ip6->
protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
460 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
468 while (n_left_from > 0)
472 while (n_left_from > 0 && n_left_to_next > 0)
476 ip4_mapt_pseudo_header_t *pheader0;
477 ip4_mapt_tcp_udp_next_t next0;
479 pi0 = to_next[0] = from[0];
514 to_next, n_left_to_next, pi0,
526 u8 * error0, ip4_mapt_next_t * next0)
538 *error0 = (*dst_port0 == -1) ? MAP_ERROR_FRAGMENT_MEMORY : *error0;
545 *error0 = ip4_len0 < 40 ? MAP_ERROR_MALFORMED : *error0;
552 *error0 = ip4_len0 < 28 ? MAP_ERROR_MALFORMED : *error0;
555 else if (ip40->
protocol == IP_PROTOCOL_ICMP)
560 else if (((icmp46_header_t *)
u8_ptr_add (ip40,
sizeof (*ip40)))->code
562 || ((icmp46_header_t *)
564 sizeof (*ip40)))->code == ICMP4_echo_request)
569 *error0 = MAP_ERROR_BAD_PROTOCOL;
576 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
585 while (n_left_from > 0)
589 while (n_left_from > 0 && n_left_to_next > 0)
595 ip4_mapt_next_t next0 = 0;
599 ip4_mapt_pseudo_header_t *pheader0;
601 pi0 = to_next[0] = from[0];
606 error0 = MAP_ERROR_NONE;
610 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
614 error0 = MAP_ERROR_UNKNOWN;
635 && (clib_net_to_host_u16 (dst_port0) <
638 error0 = MAP_ERROR_SEC_CHECK;
648 pheader0->daddr.as_u64[0] =
650 pheader0->daddr.as_u64[1] =
660 && ip4_map_fragment_cache (ip40, dst_port0)))
662 error0 = MAP_ERROR_UNKNOWN;
671 map_t.map_domain_index, 1,
680 to_next, n_left_to_next, pi0,
688 static char *map_t_error_strings[] = {
689 #define _(sym,string) string, 696 .arc_name =
"ip4-unicast",.node_name =
"ip4-map-t",.runs_before =
702 .name =
"ip4-map-t-fragmented",
703 .vector_size =
sizeof(
u32),
708 .error_strings = map_t_error_strings,
723 .name =
"ip4-map-t-icmp",
724 .vector_size =
sizeof(
u32),
729 .error_strings = map_t_error_strings,
744 .name =
"ip4-map-t-tcp-udp",
745 .vector_size =
sizeof(
u32),
750 .error_strings = map_t_error_strings,
766 .vector_size =
sizeof(
u32),
771 .error_strings = map_t_error_strings,
#define map_ip4_reass_lock()
VNET_FEATURE_INIT(ip4_map_t_feature, static)
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)
u16 current_length
Nbytes between current data and the end of this buffer.
static_always_inline map_domain_t * ip4_map_get_domain(ip4_address_t *addr, u32 *map_domain_index, u8 *error)
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
static_always_inline i32 ip4_map_fragment_get_port(ip4_header_t *ip4)
vlib_error_t * errors
Vector of errors for this node.
struct _tcp_header tcp_header_t
IPv4 to IPv6 translation.
static uword ip4_map_t_icmp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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 u8_ptr_add(ptr, index)
#define static_always_inline
vlib_combined_counter_main_t * domain_counters
ip4_mapt_fragmented_next_t
static void * ip4_next_header(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.
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
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)
#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).
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
#define VLIB_REGISTER_NODE(x,...)
static int map_ip4_to_ip6_fragmented(vlib_buffer_t *p, ip4_mapt_pseudo_header_t *pheader)
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
typedef CLIB_PACKED(struct { ip6_address_t daddr;ip6_address_t saddr;u8 unused[28];})
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
static int map_ip4_to_ip6_tcp_udp(vlib_buffer_t *p, ip4_mapt_pseudo_header_t *pheader)
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_always_inline bool ip4_map_ip6_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
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 VNET_FEATURES(...)
static_always_inline void map_mss_clamping(tcp_header_t *tcp, ip_csum_t *sum, u16 mss_clamping)
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)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
#define u16_net_add(u, val)
#define ip6_frag_hdr_offset_and_more(offset, more)
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip_csum_fold(ip_csum_t c)
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)