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);
137 ip6) ? MAP_ERROR_NONE :
138 MAP_ERROR_DECAP_SEC_CHECK;
142 *error = MAP_ERROR_BAD_PROTOCOL;
161 #ifdef MAP_SKIP_IP6_LOOKUP 178 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
188 while (n_left_from > 0)
193 while (n_left_from >= 4 && n_left_to_next >= 2)
197 u8 error0 = MAP_ERROR_NONE;
198 u8 error1 = MAP_ERROR_NONE;
202 u16 port0 = 0, port1 = 0;
203 u32 map_domain_index0 = ~0, map_domain_index1 = ~0;
222 pi0 = to_next[0] = from[0];
223 pi1 = to_next[1] = from[1];
249 (ip60->
protocol == IP_PROTOCOL_IP_IN_IP
257 else if (ip60->
protocol == IP_PROTOCOL_ICMP6 &&
259 sizeof (icmp46_header_t))
261 icmp46_header_t *icmp = (
void *) (ip60 + 1);
262 next0 = (icmp->type == ICMP6_echo_request
267 else if (ip60->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION)
269 error0 = MAP_ERROR_FRAGMENTED;
273 error0 = MAP_ERROR_BAD_PROTOCOL;
276 (ip61->
protocol == IP_PROTOCOL_IP_IN_IP
284 else if (ip61->
protocol == IP_PROTOCOL_ICMP6 &&
286 sizeof (icmp46_header_t))
288 icmp46_header_t *icmp = (
void *) (ip61 + 1);
289 next1 = (icmp->type == ICMP6_echo_request
294 else if (ip61->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION)
296 error1 = MAP_ERROR_FRAGMENTED;
300 error1 = MAP_ERROR_BAD_PROTOCOL;
313 && (clib_host_to_net_u16 (ip40->
length) > d0->
mtu)))
330 map_domain_index0, 1,
345 && (clib_host_to_net_u16 (ip41->
length) > d1->mtu)))
362 map_domain_index1, 1,
378 if (error0 == MAP_ERROR_DECAP_SEC_CHECK && mm->
icmp6_enabled)
383 ICMP6_destination_unreachable_source_address_failed_policy,
392 if (error1 == MAP_ERROR_DECAP_SEC_CHECK && mm->
icmp6_enabled)
397 ICMP6_destination_unreachable_source_address_failed_policy,
415 n_left_to_next, pi0, pi1, next0,
420 while (n_left_from > 0 && n_left_to_next > 0)
424 u8 error0 = MAP_ERROR_NONE;
429 u32 map_domain_index0 = ~0;
432 pi0 = to_next[0] = from[0];
454 (ip60->
protocol == IP_PROTOCOL_IP_IN_IP
462 else if (ip60->
protocol == IP_PROTOCOL_ICMP6 &&
464 sizeof (icmp46_header_t))
466 icmp46_header_t *icmp = (
void *) (ip60 + 1);
467 next0 = (icmp->type == ICMP6_echo_request
472 else if (ip60->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION &&
473 (((ip6_frag_hdr_t *) (ip60 + 1))->next_hdr ==
474 IP_PROTOCOL_IP_IN_IP))
476 error0 = MAP_ERROR_FRAGMENTED;
496 && (clib_host_to_net_u16 (ip40->
length) > d0->
mtu)))
513 map_domain_index0, 1,
525 (error0 == MAP_ERROR_DECAP_SEC_CHECK
526 || error0 == MAP_ERROR_NO_DOMAIN))
531 ICMP6_destination_unreachable_source_address_failed_policy,
546 n_left_to_next, pi0, next0);
571 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
581 while (n_left_from > 0)
586 while (n_left_from > 0 && n_left_to_next > 0)
590 u8 error0 = MAP_ERROR_NONE;
595 u32 map_domain_index0 = ~0;
598 pi0 = to_next[0] = from[0];
610 &map_domain_index0, &error0);
617 ip60) ? MAP_ERROR_NONE :
618 MAP_ERROR_DECAP_SEC_CHECK;
621 (error0 == MAP_ERROR_NONE &&
622 d0->
mtu && (clib_host_to_net_u16 (ip40->
length) > d0->
mtu)))
638 if (error0 == MAP_ERROR_NONE)
641 map_domain_index0, 1,
649 n_left_to_next, pi0, next0);
664 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
669 u16 *fragment_ids, *fid;
678 n_left_from * sizeof (fragment_ids[0]));
680 while (n_left_from > 0)
685 while (n_left_from > 0 && n_left_to_next > 0)
689 u8 error0 = MAP_ERROR_NONE;
694 pi0 = to_next[0] = from[0];
719 error0 = MAP_ERROR_ICMP_RELAY;
723 icmp46_header_t *icmp60 = (icmp46_header_t *) (ip60 + 1);
726 if (inner_ip60->
protocol != IP_PROTOCOL_IP_IN_IP)
728 error0 = MAP_ERROR_ICMP_RELAY;
735 icmp46_header_t *new_icmp40 = (icmp46_header_t *) (new_ip40 + 1);
740 switch (icmp60->type)
742 case ICMP6_destination_unreachable:
743 case ICMP6_time_exceeded:
744 case ICMP6_parameter_problem:
746 new_icmp40->type = ICMP4_destination_unreachable;
748 ICMP4_destination_unreachable_destination_unreachable_host;
751 case ICMP6_packet_too_big:
754 mtu = clib_net_to_host_u32 (*((
u32 *) (icmp60 + 1)));
761 error0 = MAP_ERROR_ICMP_RELAY;
765 new_icmp40->type = ICMP4_destination_unreachable;
767 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set;
768 *((
u32 *) (new_icmp40 + 1)) =
769 clib_host_to_net_u32 (mtu < 1280 ? 1280 : mtu);
773 error0 = MAP_ERROR_ICMP_RELAY;
782 u16 nlen = (tlen - 20) > 576 ? 576 : tlen - 20;
783 new_ip40->
length = clib_host_to_net_u16 (nlen);
787 new_ip40->
protocol = IP_PROTOCOL_ICMP;
792 new_icmp40->checksum = 0;
811 n_left_to_next, pi0, next0);
821 #define _(sym,string) string, 829 .arc_name =
"ip6-unicast",
830 .node_name =
"ip6-map",
838 .vector_size =
sizeof(
u32),
848 #ifdef MAP_SKIP_IP6_LOOKUP 864 .name =
"ip6-map-post-ip4-reass",
865 .vector_size =
sizeof(
u32),
882 .name =
"ip6-map-icmp-relay",
883 .vector_size =
sizeof(
u32),
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)
dpo_id_t dpo
The Load-balance object index to use to forward.
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 char * map_error_strings[]
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
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)
map_main_pre_resolved_t pre_resolved[FIB_PROTOCOL_MAX]
Pre-resolved per-protocol global next-hops.
#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.
#define foreach_map_error
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_always_inline bool ip6_map_ip4_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
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)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
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
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static_always_inline u64 map_get_sfx(map_domain_t *d, u32 addr, u16 port)
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)