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);
108 u32 sa4 = clib_net_to_host_u32 (
ip4->src_address.as_u32);
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;
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,
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);
537 return frame->n_vectors;
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);
640 return frame->n_vectors;
655 u16 *fragment_ids, *fid;
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);
802 return frame->n_vectors;
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,