114 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
123 while (n_left_from > 0)
127 while (n_left_from > 0 && n_left_to_next > 0)
138 pi0 = to_next[0] = from[0];
143 error0 = MAP_ERROR_NONE;
156 NULL, NULL, NULL, NULL))
161 error0 = MAP_ERROR_ICMP;
169 error0 = MAP_ERROR_ICMP;
191 map_t.map_domain_index, 1,
201 to_next, n_left_to_next, pi0,
216 ip6_frag_hdr_t *frag;
227 (vm, p, ip6, p->
current_length, &l4_protocol, &l4_offset, &frag_offset))
230 frag = (ip6_frag_hdr_t *)
u8_ptr_add (ip6, frag_offset);
246 sizeof (*ip4) - l4_offset +
sizeof (*ip6));
249 clib_host_to_net_u16 (frag_offset |
253 (l4_protocol == IP_PROTOCOL_ICMP6) ? IP_PROTOCOL_ICMP : l4_protocol;
263 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
270 while (n_left_from > 0)
274 while (n_left_from > 0 && n_left_to_next > 0)
280 pi0 = to_next[0] = from[0];
290 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
311 to_next, n_left_to_next, pi0,
338 ip6_address_t old_src, old_dst;
343 (vm, p, ip6, p->
current_length, &l4_protocol, &l4_offset, &frag_offset))
346 if (l4_protocol == IP_PROTOCOL_TCP)
351 csum = tcp->checksum;
355 checksum = &tcp->checksum;
375 ip6_frag_hdr_t *hdr = (ip6_frag_hdr_t *)
u8_ptr_add (ip6, frag_offset);
391 u32 map_domain_index = -1;
403 sizeof (*ip4) +
sizeof (*ip6) - l4_offset);
411 if (!udp_checksum && l4_protocol == IP_PROTOCOL_UDP)
433 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
440 while (n_left_from > 0)
444 while (n_left_from > 0 && n_left_to_next > 0)
450 pi0 = to_next[0] = from[0];
482 to_next, n_left_to_next, pi0,
493 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
503 while (n_left_from > 0)
507 while (n_left_from > 0 && n_left_to_next > 0)
516 ip6_frag_hdr_t *frag0;
520 pi0 = to_next[0] = from[0];
525 error0 = MAP_ERROR_NONE;
552 ICMP6_time_exceeded_ttl_exceeded_in_transit,
554 p0->
error = error_node->
errors[MAP_ERROR_TIME_EXCEEDED];
566 error0 == MAP_ERROR_NONE ? MAP_ERROR_MALFORMED : error0;
571 sizeof (*ip60) -
vnet_buffer (p0)->map_t.v6.l4_offset;
581 map_port0 = l4_src_port;
586 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_TCP))
594 map_port0 = l4_src_port;
598 (
vnet_buffer (p0)->map_t.v6.l4_protocol == IP_PROTOCOL_UDP))
606 map_port0 = l4_src_port;
613 sizeof (icmp46_header_t) ? MAP_ERROR_MALFORMED : error0;
615 if (((icmp46_header_t *)
619 || ((icmp46_header_t *)
622 type == ICMP6_echo_request)
623 map_port0 = l4_src_port;
629 error0 = MAP_ERROR_BAD_PROTOCOL;
645 error0 == MAP_ERROR_NONE ? MAP_ERROR_SEC_CHECK : error0;
655 clib_net_to_host_u16 (ip60->
663 ICMP6_destination_unreachable_source_address_failed_policy,
682 to_next, n_left_to_next, pi0,
693 .name =
"ip6-map-t-fragmented",
694 .vector_size =
sizeof (
u32),
698 .n_errors = MAP_N_ERROR,
699 .error_counters = map_error_counters,
715 .name =
"ip6-map-t-icmp",
716 .vector_size =
sizeof (
u32),
720 .n_errors = MAP_N_ERROR,
721 .error_counters = map_error_counters,
737 .name =
"ip6-map-t-tcp-udp",
738 .vector_size =
sizeof (
u32),
742 .n_errors = MAP_N_ERROR,
743 .error_counters = map_error_counters,
758 .arc_name =
"ip6-unicast",
759 .node_name =
"ip6-map-t",
767 .vector_size =
sizeof(
u32),
771 .n_errors = MAP_N_ERROR,
772 .error_counters = map_error_counters,
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static void map_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, u32 map_domain_index, u16 port)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
static uword ip6_map_t_tcp_udp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vl_api_wireguard_peer_flags_t flags
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.
u16 udp_checksum(udp_header_t *uh, u32 udp_len, void *ih, u8 version)
static int map_ip6_to_ip4_tcp_udp(vlib_main_t *vm, vlib_buffer_t *p, bool udp_checksum)
static_always_inline map_domain_t * ip6_map_get_domain(ip6_address_t *addr, u32 *map_domain_index, u8 *error)
u16 current_length
Nbytes between current data and the end of this buffer.
static uword ip6_map_t(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline map_domain_t * ip4_map_get_domain(ip4_address_t *addr, u32 *map_domain_index, u8 *error)
static int ip6_to_ip4_set_icmp_cb(ip6_header_t *ip6, ip4_header_t *ip4, void *arg)
static_always_inline bool ip6_map_ip4_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
static u16 ip6_get_port(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6, u16 buffer_len, u8 *ip_protocol, u16 *src_port, u16 *dst_port, u8 *icmp_type_or_tcp_flags, u32 *tcp_ack_number, u32 *tcp_seq_number)
Get L4 information like port number or ICMP id from IPv6 packet.
vlib_error_t * errors
Vector of errors for this node.
struct _tcp_header tcp_header_t
IPv4 to IPv6 translation.
#define u8_ptr_add(ptr, index)
static_always_inline u32 ip6_map_t_embedded_address(map_domain_t *d, ip6_address_t *addr)
static_always_inline u32 map_get_ip4(ip6_address_t *addr, u16 prefix_len)
vlib_combined_counter_main_t * domain_counters
static_always_inline u8 ip6_translate_tos(u32 ip_version_traffic_class_and_flow_label)
Translate TOS value from IPv6 to IPv4.
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
vl_api_fib_path_type_t type
#define ip6_frag_hdr_more(hdr)
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.
#define IP4_FRAG_NODE_NAME
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
vlib_node_registration_t ip6_map_t_tcp_udp_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_tcp_udp_node)
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.
#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_node_registration_t ip6_map_t_fragmented_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_fragmented_node)
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
#define VLIB_REGISTER_NODE(x,...)
static uword ip6_map_t_icmp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
VNET_FEATURE_INIT(ip6_map_t_feature, static)
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.
vlib_main_t vlib_node_runtime_t * node
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.
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
u8 * format_map_trace(u8 *s, va_list *args)
IPv6 to IPv4 translation.
#define VNET_FEATURES(...)
static_always_inline void map_mss_clamping(tcp_header_t *tcp, ip_csum_t *sum, u16 mss_clamping)
static uword ip6_map_t_fragmented(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static int icmp6_to_icmp(vlib_main_t *vm, vlib_buffer_t *p, ip6_to_ip4_icmp_set_fn_t fn, void *ctx, ip6_to_ip4_icmp_set_fn_t inner_fn, void *inner_ctx)
Translate ICMP6 packet to ICMP4.
vlib_main_t vlib_node_runtime_t 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.
vlib_node_registration_t ip6_map_t_node
(constructor) VLIB_REGISTER_NODE (ip6_map_t_node)
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS
#define u16_net_add(u, val)
static_always_inline int ip6_parse(vlib_main_t *vm, vlib_buffer_t *b, 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.
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 u16 ip4_header_checksum(ip4_header_t *i)
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)
static int map_ip6_to_ip4_fragmented(vlib_main_t *vm, vlib_buffer_t *p)