62 }) ip4_mapt_pseudo_header_t;
75 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->
protocol,
93 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->
protocol,
141 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
150 while (n_left_from > 0)
154 while (n_left_from > 0 && n_left_to_next > 0)
158 ip4_mapt_icmp_next_t next0;
166 pi0 = to_next[0] = from[0];
171 error0 = MAP_ERROR_NONE;
190 error0 = MAP_ERROR_ICMP;
199 error0 = MAP_ERROR_ICMP;
215 map_t.map_domain_index, 1,
224 to_next, n_left_to_next, pi0,
237 ip4_mapt_pseudo_header_t * pheader)
241 ip6_frag_hdr_t *frag;
244 frag = (ip6_frag_hdr_t *)
u8_ptr_add (ip4,
sizeof (*ip4) -
sizeof (*frag));
247 sizeof (*ip4) -
sizeof (*frag) -
257 frag->fragment_offset_and_more =
264 clib_host_to_net_u32 ((6 << 28) + (ip4->
tos << 20));
266 clib_host_to_net_u16 (clib_net_to_host_u16 (ip4->
length) -
267 sizeof (*ip4) +
sizeof (*frag));
269 ip6->
protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
283 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
290 while (n_left_from > 0)
294 while (n_left_from > 0 && n_left_to_next > 0)
298 ip4_mapt_pseudo_header_t *pheader0;
299 ip4_mapt_fragmented_next_t next0;
302 pi0 = to_next[0] = from[0];
316 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
331 to_next, n_left_to_next, pi0,
350 ip6_frag_hdr_t *frag;
356 if (ip4->
protocol == IP_PROTOCOL_UDP)
368 u16 udp_len = clib_host_to_net_u16 (ip4->
length) -
sizeof (*ip4);
382 csum = tcp->checksum;
386 checksum = &tcp->checksum;
398 sizeof (*ip4) -
sizeof (*ip6) -
401 (ip6_frag_hdr_t *)
u8_ptr_add (ip4,
sizeof (*ip4) -
sizeof (*frag));
407 ip6 = (
ip6_header_t *) (((
u8 *) ip4) +
sizeof (*ip4) -
sizeof (*ip6));
413 clib_host_to_net_u32 ((6 << 28) + (ip4->
tos << 20));
420 frag->identification = frag_id;
423 ip6->
protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
447 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
455 while (n_left_from > 0)
459 while (n_left_from > 0 && n_left_to_next > 0)
463 ip4_mapt_pseudo_header_t *pheader0;
464 ip4_mapt_tcp_udp_next_t next0;
466 pi0 = to_next[0] = from[0];
496 to_next, n_left_to_next, pi0,
508 u8 * error0, ip4_mapt_next_t * next0)
520 *error0 = (*dst_port0 == -1) ? MAP_ERROR_FRAGMENT_MEMORY : *error0;
527 *error0 = ip4_len0 < 40 ? MAP_ERROR_MALFORMED : *error0;
534 *error0 = ip4_len0 < 28 ? MAP_ERROR_MALFORMED : *error0;
537 else if (ip40->
protocol == IP_PROTOCOL_ICMP)
542 else if (((icmp46_header_t *)
u8_ptr_add (ip40,
sizeof (*ip40)))->code
544 || ((icmp46_header_t *)
546 sizeof (*ip40)))->code == ICMP4_echo_request)
551 *error0 = MAP_ERROR_BAD_PROTOCOL;
558 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
567 while (n_left_from > 0)
571 while (n_left_from > 0 && n_left_to_next > 0)
577 ip4_mapt_next_t next0 = 0;
581 ip4_mapt_pseudo_header_t *pheader0;
583 pi0 = to_next[0] = from[0];
588 error0 = MAP_ERROR_NONE;
592 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
596 error0 = MAP_ERROR_UNKNOWN;
617 && (clib_net_to_host_u16 (dst_port0) <
620 error0 = MAP_ERROR_SEC_CHECK;
630 pheader0->daddr.as_u64[0] =
632 pheader0->daddr.as_u64[1] =
642 && ip4_map_fragment_cache (ip40, dst_port0)))
644 error0 = MAP_ERROR_UNKNOWN;
653 map_t.map_domain_index, 1,
662 to_next, n_left_to_next, pi0,
670 static char *map_t_error_strings[] = {
671 #define _(sym,string) string, 678 .arc_name =
"ip4-unicast",.node_name =
"ip4-map-t",.runs_before =
684 .name =
"ip4-map-t-fragmented",
685 .vector_size =
sizeof(
u32),
690 .error_strings = map_t_error_strings,
704 .name =
"ip4-map-t-icmp",
705 .vector_size =
sizeof(
u32),
710 .error_strings = map_t_error_strings,
724 .name =
"ip4-map-t-tcp-udp",
725 .vector_size =
sizeof(
u32),
730 .error_strings = map_t_error_strings,
745 .vector_size =
sizeof(
u32),
750 .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)
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 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.
#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)
#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 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 ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
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 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 u8_ptr_add(ptr, index)
#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)
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 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)