25 #ifdef MAP_SKIP_IP6_LOOKUP 77 return format (s,
"MAP domain index: %d L4 port: %u Status: %s",
79 t->
cached ?
"cached" :
"forwarded");
96 return format (s,
"Offset: %d Fragment length: %d Status: %s", t->
offset,
107 u16 sp4 = clib_net_to_host_u16 (port);
113 (sal6 != clib_net_to_host_u64 (ip6->
src_address.as_u64[0])
114 || sar6 != clib_net_to_host_u64 (ip6->
src_address.as_u64[1])))
137 ip6) ? MAP_ERROR_NONE :
138 MAP_ERROR_DECAP_SEC_CHECK;
142 *error = MAP_ERROR_BAD_PROTOCOL;
164 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
174 while (n_left_from > 0)
179 while (n_left_from >= 4 && n_left_to_next >= 2)
183 u8 error0 = MAP_ERROR_NONE;
184 u8 error1 = MAP_ERROR_NONE;
188 u16 port0 = 0, port1 = 0;
189 u32 map_domain_index0 = ~0, map_domain_index1 = ~0;
208 pi0 = to_next[0] = from[0];
209 pi1 = to_next[1] = from[1];
235 (ip60->
protocol == IP_PROTOCOL_IP_IN_IP
243 else if (ip60->
protocol == IP_PROTOCOL_ICMP6 &&
245 sizeof (icmp46_header_t))
247 icmp46_header_t *
icmp = (
void *) (ip60 + 1);
248 next0 = (icmp->type == ICMP6_echo_request
253 else if (ip60->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION)
255 error0 = MAP_ERROR_FRAGMENTED;
259 error0 = MAP_ERROR_BAD_PROTOCOL;
262 (ip61->
protocol == IP_PROTOCOL_IP_IN_IP
270 else if (ip61->
protocol == IP_PROTOCOL_ICMP6 &&
272 sizeof (icmp46_header_t))
274 icmp46_header_t *
icmp = (
void *) (ip61 + 1);
275 next1 = (icmp->type == ICMP6_echo_request
280 else if (ip61->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION)
282 error1 = MAP_ERROR_FRAGMENTED;
286 error1 = MAP_ERROR_BAD_PROTOCOL;
299 && (clib_host_to_net_u16 (ip40->
length) > d0->
mtu)))
316 map_domain_index0, 1,
331 && (clib_host_to_net_u16 (ip41->
length) > d1->mtu)))
348 map_domain_index1, 1,
364 if (error0 == MAP_ERROR_DECAP_SEC_CHECK && mm->
icmp6_enabled)
369 ICMP6_destination_unreachable_source_address_failed_policy,
378 if (error1 == MAP_ERROR_DECAP_SEC_CHECK && mm->
icmp6_enabled)
383 ICMP6_destination_unreachable_source_address_failed_policy,
401 n_left_to_next, pi0, pi1, next0,
406 while (n_left_from > 0 && n_left_to_next > 0)
410 u8 error0 = MAP_ERROR_NONE;
415 u32 map_domain_index0 = ~0;
418 pi0 = to_next[0] = from[0];
440 (ip60->
protocol == IP_PROTOCOL_IP_IN_IP
448 else if (ip60->
protocol == IP_PROTOCOL_ICMP6 &&
450 sizeof (icmp46_header_t))
452 icmp46_header_t *
icmp = (
void *) (ip60 + 1);
453 next0 = (icmp->type == ICMP6_echo_request
458 else if (ip60->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION &&
459 (((ip6_frag_hdr_t *) (ip60 + 1))->next_hdr ==
460 IP_PROTOCOL_IP_IN_IP))
462 error0 = MAP_ERROR_FRAGMENTED;
482 && (clib_host_to_net_u16 (ip40->
length) > d0->
mtu)))
499 map_domain_index0, 1,
511 (error0 == MAP_ERROR_DECAP_SEC_CHECK
512 || error0 == MAP_ERROR_NO_DOMAIN))
517 ICMP6_destination_unreachable_source_address_failed_policy,
532 n_left_to_next, pi0, next0);
557 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
567 while (n_left_from > 0)
572 while (n_left_from > 0 && n_left_to_next > 0)
576 u8 error0 = MAP_ERROR_NONE;
581 u32 map_domain_index0 = ~0;
584 pi0 = to_next[0] = from[0];
596 &map_domain_index0, &error0);
603 ip60) ? MAP_ERROR_NONE :
604 MAP_ERROR_DECAP_SEC_CHECK;
607 (error0 == MAP_ERROR_NONE &&
608 d0->
mtu && (clib_host_to_net_u16 (ip40->
length) > d0->
mtu)))
624 if (error0 == MAP_ERROR_NONE)
627 map_domain_index0, 1,
635 n_left_to_next, pi0, next0);
650 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
655 u16 *fragment_ids, *fid;
664 n_left_from * sizeof (fragment_ids[0]));
666 while (n_left_from > 0)
671 while (n_left_from > 0 && n_left_to_next > 0)
675 u8 error0 = MAP_ERROR_NONE;
680 pi0 = to_next[0] = from[0];
705 error0 = MAP_ERROR_ICMP_RELAY;
709 icmp46_header_t *icmp60 = (icmp46_header_t *) (ip60 + 1);
712 if (inner_ip60->
protocol != IP_PROTOCOL_IP_IN_IP)
714 error0 = MAP_ERROR_ICMP_RELAY;
721 icmp46_header_t *new_icmp40 = (icmp46_header_t *) (new_ip40 + 1);
726 switch (icmp60->type)
728 case ICMP6_destination_unreachable:
729 case ICMP6_time_exceeded:
730 case ICMP6_parameter_problem:
732 new_icmp40->type = ICMP4_destination_unreachable;
734 ICMP4_destination_unreachable_destination_unreachable_host;
737 case ICMP6_packet_too_big:
740 mtu = clib_net_to_host_u32 (*((
u32 *) (icmp60 + 1)));
747 error0 = MAP_ERROR_ICMP_RELAY;
751 new_icmp40->type = ICMP4_destination_unreachable;
753 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set;
754 *((
u32 *) (new_icmp40 + 1)) =
755 clib_host_to_net_u32 (mtu < 1280 ? 1280 : mtu);
759 error0 = MAP_ERROR_ICMP_RELAY;
768 u16 nlen = (tlen - 20) > 576 ? 576 : tlen - 20;
769 new_ip40->
length = clib_host_to_net_u16 (nlen);
773 new_ip40->
protocol = IP_PROTOCOL_ICMP;
778 new_icmp40->checksum = 0;
797 n_left_to_next, pi0, next0);
809 .arc_name =
"ip6-unicast",
810 .node_name =
"ip6-map",
818 .vector_size =
sizeof(
u32),
822 .n_errors = MAP_N_ERROR,
823 .error_counters = map_error_counters,
828 #ifdef MAP_SKIP_IP6_LOOKUP 844 .name =
"ip6-map-post-ip4-reass",
845 .vector_size =
sizeof(
u32),
848 .n_errors = MAP_N_ERROR,
849 .error_counters = map_error_counters,
862 .name =
"ip6-map-icmp-relay",
863 .vector_size =
sizeof(
u32),
866 .n_errors = MAP_N_ERROR,
867 .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_always_inline bool ip6_map_sec_check(map_domain_t *d, u16 port, ip4_header_t *ip4, ip6_header_t *ip6)
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.
static_always_inline u64 map_get_pfx(map_domain_t *d, u32 addr, u16 port)
static void vlib_set_next_frame_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 buffer_index)
static uword ip6_map_post_ip4_reass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * clib_random_buffer_get_data(clib_random_buffer_t *b, uword n_bytes)
static_always_inline map_domain_t * ip4_map_get_domain(ip4_address_t *addr, u32 *map_domain_index, u8 *error)
ip6_map_post_ip4_reass_next_e
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
static_always_inline bool ip6_map_ip4_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
vlib_error_t * errors
Vector of errors for this node.
vlib_node_registration_t ip6_map_node
(constructor) VLIB_REGISTER_NODE (ip6_map_node)
IPv4 to IPv6 translation.
static int ip4_is_fragment(const ip4_header_t *i)
#define static_always_inline
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * domain_counters
ip4_address_t icmp4_src_address
description fragment has unexpected format
vlib_node_registration_t ip6_map_ip6_reass_node
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_simple_counter_main_t icmp_relayed
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
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.
clib_error_t * ip6_map_init(vlib_main_t *vm)
VNET_FEATURE_INIT(ip6_map_feature, static)
IPv4 shallow virtual reassembly.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vl_api_address_union_t src_address
#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).
u8 * format_ip6_map_post_ip4_reass_trace(u8 *s, va_list *args)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
vlib_node_registration_t ip6_map_post_ip4_reass_node
(constructor) VLIB_REGISTER_NODE (ip6_map_post_ip4_reass_node)
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.
static uword ip6_map_icmp_relay(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline void ip6_map_security_check(map_domain_t *d, vlib_buffer_t *b0, ip4_header_t *ip4, ip6_header_t *ip6, u32 *next, u8 *error)
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
static uword ip6_map(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static vlib_node_registration_t ip6_map_icmp_relay_node
(constructor) VLIB_REGISTER_NODE (ip6_map_icmp_relay_node)
u8 * format_map_trace(u8 *s, va_list *args)
IPv6 to IPv4 translation.
u8 * format_ip6_map_ip6_reass_trace(u8 *s, va_list *args)
#define VNET_FEATURES(...)
static vlib_main_t * vlib_get_main(void)
struct _vlib_node_registration vlib_node_registration_t
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.
uword ip4_sv_reass_custom_next_index
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static_always_inline u64 map_get_sfx(map_domain_t *d, u32 addr, u16 port)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
uword ip4_sv_reass_custom_register_next_node(uword node_index)
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)
clib_random_buffer_t random_buffer
static u16 ip_csum_fold(ip_csum_t c)
void map_ip6_drop_pi(u32 pi)