2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include "../ip/ip_frag.h"
19 #define IP4_MAP_T_DUAL_LOOP 1
23 IP4_MAPT_NEXT_MAPT_TCP_UDP,
24 IP4_MAPT_NEXT_MAPT_ICMP,
25 IP4_MAPT_NEXT_MAPT_FRAGMENTED,
32 IP4_MAPT_ICMP_NEXT_IP6_LOOKUP,
33 IP4_MAPT_ICMP_NEXT_IP6_FRAG,
34 IP4_MAPT_ICMP_NEXT_DROP,
36 } ip4_mapt_icmp_next_t;
40 IP4_MAPT_TCP_UDP_NEXT_IP6_LOOKUP,
41 IP4_MAPT_TCP_UDP_NEXT_IP6_FRAG,
42 IP4_MAPT_TCP_UDP_NEXT_DROP,
43 IP4_MAPT_TCP_UDP_N_NEXT
44 } ip4_mapt_tcp_udp_next_t;
48 IP4_MAPT_FRAGMENTED_NEXT_IP6_LOOKUP,
49 IP4_MAPT_FRAGMENTED_NEXT_IP6_FRAG,
50 IP4_MAPT_FRAGMENTED_NEXT_DROP,
51 IP4_MAPT_FRAGMENTED_N_NEXT
52 } ip4_mapt_fragmented_next_t;
54 //This is used to pass information within the buffer data.
55 //Buffer structure being too small to contain big structures like this.
57 typedef CLIB_PACKED (struct {
60 //IPv6 header + Fragmentation header will be here
61 //sizeof(ip6) + sizeof(ip_frag) - sizeof(ip4)
63 }) ip4_mapt_pseudo_header_t;
66 #define frag_id_4to6(id) (id)
68 //TODO: Find the right place in memory for this.
70 static u8 icmp_to_icmp6_updater_pointer_table[] =
79 static_always_inline int
80 ip4_map_fragment_cache (ip4_header_t * ip4, u16 port)
83 map_ip4_reass_lock ();
85 map_ip4_reass_get (ip4->src_address.as_u32, ip4->dst_address.as_u32,
88 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->protocol,
93 map_ip4_reass_unlock ();
97 static_always_inline i32
98 ip4_map_fragment_get_port (ip4_header_t * ip4)
101 map_ip4_reass_lock ();
103 map_ip4_reass_get (ip4->src_address.as_u32, ip4->dst_address.as_u32,
106 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip4->protocol,
108 i32 ret = r ? r->port : -1;
109 map_ip4_reass_unlock ();
114 /* Statelessly translates an ICMP packet into ICMPv6.
116 * Warning: The checksum will need to be recomputed.
119 static_always_inline int
120 ip4_icmp_to_icmp6_in_place (icmp46_header_t * icmp, u32 icmp_len,
121 i32 * receiver_port, ip4_header_t ** inner_ip4)
126 case ICMP4_echo_reply:
127 *receiver_port = ((u16 *) icmp)[2];
128 icmp->type = ICMP6_echo_reply;
130 case ICMP4_echo_request:
131 *receiver_port = ((u16 *) icmp)[2];
132 icmp->type = ICMP6_echo_request;
134 case ICMP4_destination_unreachable:
135 *inner_ip4 = (ip4_header_t *) (((u8 *) icmp) + 8);
136 *receiver_port = ip4_get_port (*inner_ip4, MAP_SENDER, icmp_len - 8);
140 case ICMP4_destination_unreachable_destination_unreachable_net: //0
141 case ICMP4_destination_unreachable_destination_unreachable_host: //1
142 icmp->type = ICMP6_destination_unreachable;
143 icmp->code = ICMP6_destination_unreachable_no_route_to_destination;
145 case ICMP4_destination_unreachable_protocol_unreachable: //2
146 icmp->type = ICMP6_parameter_problem;
147 icmp->code = ICMP6_parameter_problem_unrecognized_next_header;
149 case ICMP4_destination_unreachable_port_unreachable: //3
150 icmp->type = ICMP6_destination_unreachable;
151 icmp->code = ICMP6_destination_unreachable_port_unreachable;
153 case ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set: //4
155 ICMP6_packet_too_big;
158 u32 advertised_mtu = clib_net_to_host_u32 (*((u32 *) (icmp + 1)));
160 advertised_mtu += 20;
162 advertised_mtu = 1000; //FIXME ! (RFC 1191 - plateau value)
164 //FIXME: = minimum(advertised MTU+20, MTU_of_IPv6_nexthop, (MTU_of_IPv4_nexthop)+20)
165 *((u32 *) (icmp + 1)) = clib_host_to_net_u32 (advertised_mtu);
169 case ICMP4_destination_unreachable_source_route_failed: //5
170 case ICMP4_destination_unreachable_destination_network_unknown: //6
171 case ICMP4_destination_unreachable_destination_host_unknown: //7
172 case ICMP4_destination_unreachable_source_host_isolated: //8
173 case ICMP4_destination_unreachable_network_unreachable_for_type_of_service: //11
174 case ICMP4_destination_unreachable_host_unreachable_for_type_of_service: //12
176 ICMP6_destination_unreachable;
177 icmp->code = ICMP6_destination_unreachable_no_route_to_destination;
179 case ICMP4_destination_unreachable_network_administratively_prohibited: //9
180 case ICMP4_destination_unreachable_host_administratively_prohibited: //10
181 case ICMP4_destination_unreachable_communication_administratively_prohibited: //13
182 case ICMP4_destination_unreachable_precedence_cutoff_in_effect: //15
183 icmp->type = ICMP6_destination_unreachable;
185 ICMP6_destination_unreachable_destination_administratively_prohibited;
187 case ICMP4_destination_unreachable_host_precedence_violation: //14
193 case ICMP4_time_exceeded: //11
194 *inner_ip4 = (ip4_header_t *) (((u8 *) icmp) + 8);
195 *receiver_port = ip4_get_port (*inner_ip4, MAP_SENDER, icmp_len - 8);
196 icmp->type = ICMP6_time_exceeded;
197 //icmp->code = icmp->code //unchanged
200 case ICMP4_parameter_problem:
201 *inner_ip4 = (ip4_header_t *) (((u8 *) icmp) + 8);
202 *receiver_port = ip4_get_port (*inner_ip4, MAP_SENDER, icmp_len - 8);
206 case ICMP4_parameter_problem_pointer_indicates_error:
207 case ICMP4_parameter_problem_bad_length:
208 icmp->type = ICMP6_parameter_problem;
209 icmp->code = ICMP6_parameter_problem_erroneous_header_field;
212 icmp_to_icmp6_updater_pointer_table[*((u8 *) (icmp + 1))];
216 *((u32 *) (icmp + 1)) = clib_host_to_net_u32 (ptr);
220 //All other codes cause dropping the packet
226 //All other types cause dropping the packet
233 static_always_inline void
234 _ip4_map_t_icmp (map_domain_t * d, vlib_buffer_t * p, u8 * error)
236 ip4_header_t *ip4, *inner_ip4;
237 ip6_header_t *ip6, *inner_ip6;
239 icmp46_header_t *icmp;
242 u16 *inner_L4_checksum = 0;
243 ip6_frag_hdr_t *inner_frag;
245 u32 inner_frag_offset;
248 ip4 = vlib_buffer_get_current (p);
249 ip_len = clib_net_to_host_u16 (ip4->length);
250 ASSERT (ip_len <= p->current_length);
252 icmp = (icmp46_header_t *) (ip4 + 1);
253 if (ip4_icmp_to_icmp6_in_place (icmp, ip_len - sizeof (*ip4),
254 &recv_port, &inner_ip4))
256 *error = MAP_ERROR_ICMP;
262 // In case of 1:1 mapping, we don't care about the port
263 if (d->ea_bits_len == 0 && d->rules)
269 *error = MAP_ERROR_ICMP;
276 //We have 2 headers to translate.
277 //We need to make some room in the middle of the packet
279 if (PREDICT_FALSE (ip4_is_fragment (inner_ip4)))
281 //Here it starts getting really tricky
282 //We will add a fragmentation header in the inner packet
284 if (!ip4_is_first_fragment (inner_ip4))
286 //For now we do not handle unless it is the first fragment
287 //Ideally we should handle the case as we are in slow path already
288 *error = MAP_ERROR_FRAGMENTED;
292 vlib_buffer_advance (p,
293 -2 * (sizeof (*ip6) - sizeof (*ip4)) -
294 sizeof (*inner_frag));
295 ip6 = vlib_buffer_get_current (p);
296 clib_memcpy (u8_ptr_add (ip6, sizeof (*ip6) - sizeof (*ip4)), ip4,
299 (ip4_header_t *) u8_ptr_add (ip6, sizeof (*ip6) - sizeof (*ip4));
300 icmp = (icmp46_header_t *) (ip4 + 1);
303 (ip6_header_t *) u8_ptr_add (inner_ip4,
304 sizeof (*ip4) - sizeof (*ip6) -
305 sizeof (*inner_frag));
307 (ip6_frag_hdr_t *) u8_ptr_add (inner_ip6, sizeof (*inner_ip6));
308 ip6->payload_length =
309 u16_net_add (ip4->length,
310 sizeof (*ip6) - 2 * sizeof (*ip4) +
311 sizeof (*inner_frag));
312 inner_frag_id = frag_id_4to6 (inner_ip4->fragment_id);
313 inner_frag_offset = ip4_get_fragment_offset (inner_ip4);
315 ! !(inner_ip4->flags_and_fragment_offset &
316 clib_net_to_host_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS));
320 vlib_buffer_advance (p, -2 * (sizeof (*ip6) - sizeof (*ip4)));
321 ip6 = vlib_buffer_get_current (p);
322 clib_memcpy (u8_ptr_add (ip6, sizeof (*ip6) - sizeof (*ip4)), ip4,
325 (ip4_header_t *) u8_ptr_add (ip6, sizeof (*ip6) - sizeof (*ip4));
326 icmp = (icmp46_header_t *) u8_ptr_add (ip4, sizeof (*ip4));
328 (ip6_header_t *) u8_ptr_add (inner_ip4,
329 sizeof (*ip4) - sizeof (*ip6));
330 ip6->payload_length =
331 u16_net_add (ip4->length, sizeof (*ip6) - 2 * sizeof (*ip4));
335 if (PREDICT_TRUE (inner_ip4->protocol == IP_PROTOCOL_TCP))
337 inner_L4_checksum = &((tcp_header_t *) (inner_ip4 + 1))->checksum;
339 ip_csum_fold (ip_csum_sub_even
341 *((u64 *) (&inner_ip4->src_address))));
343 else if (PREDICT_TRUE (inner_ip4->protocol == IP_PROTOCOL_UDP))
345 inner_L4_checksum = &((udp_header_t *) (inner_ip4 + 1))->checksum;
346 if (!*inner_L4_checksum)
348 //The inner packet was first translated, and therefore came from IPv6.
349 //As the packet was an IPv6 packet, the UDP checksum can't be NULL
350 *error = MAP_ERROR_ICMP;
354 ip_csum_fold (ip_csum_sub_even
356 *((u64 *) (&inner_ip4->src_address))));
358 else if (inner_ip4->protocol == IP_PROTOCOL_ICMP)
360 //We have an ICMP inside an ICMP
361 //It needs to be translated, but not for error ICMP messages
362 icmp46_header_t *inner_icmp = (icmp46_header_t *) (inner_ip4 + 1);
363 csum = inner_icmp->checksum;
364 //Only types ICMP4_echo_request and ICMP4_echo_reply are handled by ip4_icmp_to_icmp6_in_place
365 csum = ip_csum_sub_even (csum, *((u16 *) inner_icmp));
366 inner_icmp->type = (inner_icmp->type == ICMP4_echo_request) ?
367 ICMP6_echo_request : ICMP6_echo_reply;
368 csum = ip_csum_add_even (csum, *((u16 *) inner_icmp));
370 ip_csum_add_even (csum, clib_host_to_net_u16 (IP_PROTOCOL_ICMP6));
372 ip_csum_add_even (csum, inner_ip4->length - sizeof (*inner_ip4));
373 inner_icmp->checksum = ip_csum_fold (csum);
374 inner_L4_checksum = &inner_icmp->checksum;
375 inner_ip4->protocol = IP_PROTOCOL_ICMP6;
379 /* To shut up Coverity */
383 //FIXME: Security check with the port found in the inner packet
385 csum = *inner_L4_checksum; //Initial checksum of the inner L4 header
386 //FIXME: Shouldn't we remove ip addresses from there ?
388 inner_ip6->ip_version_traffic_class_and_flow_label =
389 clib_host_to_net_u32 ((6 << 28) + (inner_ip4->tos << 20));
390 inner_ip6->payload_length =
391 u16_net_add (inner_ip4->length, -sizeof (*inner_ip4));
392 inner_ip6->hop_limit = inner_ip4->ttl;
393 inner_ip6->protocol = inner_ip4->protocol;
395 //Note that the source address is within the domain
396 //while the destination address is the one outside the domain
397 ip4_map_t_embedded_address (d, &inner_ip6->dst_address,
398 &inner_ip4->dst_address);
399 inner_ip6->src_address.as_u64[0] =
400 map_get_pfx_net (d, inner_ip4->src_address.as_u32, recv_port);
401 inner_ip6->src_address.as_u64[1] =
402 map_get_sfx_net (d, inner_ip4->src_address.as_u32, recv_port);
404 if (PREDICT_FALSE (inner_frag != NULL))
406 inner_frag->next_hdr = inner_ip6->protocol;
407 inner_frag->identification = inner_frag_id;
409 inner_frag->fragment_offset_and_more =
410 ip6_frag_hdr_offset_and_more (inner_frag_offset, inner_frag_more);
411 inner_ip6->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
412 inner_ip6->payload_length =
413 clib_host_to_net_u16 (clib_net_to_host_u16
414 (inner_ip6->payload_length) +
415 sizeof (*inner_frag));
418 csum = ip_csum_add_even (csum, inner_ip6->src_address.as_u64[0]);
419 csum = ip_csum_add_even (csum, inner_ip6->src_address.as_u64[1]);
420 csum = ip_csum_add_even (csum, inner_ip6->dst_address.as_u64[0]);
421 csum = ip_csum_add_even (csum, inner_ip6->dst_address.as_u64[1]);
422 *inner_L4_checksum = ip_csum_fold (csum);
427 vlib_buffer_advance (p, sizeof (*ip4) - sizeof (*ip6));
428 ip6 = vlib_buffer_get_current (p);
429 ip6->payload_length =
430 clib_host_to_net_u16 (clib_net_to_host_u16 (ip4->length) -
434 //Translate outer IPv6
435 ip6->ip_version_traffic_class_and_flow_label =
436 clib_host_to_net_u32 ((6 << 28) + (ip4->tos << 20));
438 ip6->hop_limit = ip4->ttl;
439 ip6->protocol = IP_PROTOCOL_ICMP6;
441 ip4_map_t_embedded_address (d, &ip6->src_address, &ip4->src_address);
442 ip6->dst_address.as_u64[0] =
443 map_get_pfx_net (d, ip4->dst_address.as_u32, recv_port);
444 ip6->dst_address.as_u64[1] =
445 map_get_sfx_net (d, ip4->dst_address.as_u32, recv_port);
447 //Truncate when the packet exceeds the minimal IPv6 MTU
448 if (p->current_length > 1280)
450 ip6->payload_length = clib_host_to_net_u16 (1280 - sizeof (*ip6));
451 p->current_length = 1280; //Looks too simple to be correct...
454 //TODO: We could do an easy diff-checksum for echo requests/replies
455 //Recompute ICMP checksum
457 csum = ip_csum_with_carry (0, ip6->payload_length);
458 csum = ip_csum_with_carry (csum, clib_host_to_net_u16 (ip6->protocol));
459 csum = ip_csum_with_carry (csum, ip6->src_address.as_u64[0]);
460 csum = ip_csum_with_carry (csum, ip6->src_address.as_u64[1]);
461 csum = ip_csum_with_carry (csum, ip6->dst_address.as_u64[0]);
462 csum = ip_csum_with_carry (csum, ip6->dst_address.as_u64[1]);
464 ip_incremental_checksum (csum, icmp,
465 clib_net_to_host_u16 (ip6->payload_length));
466 icmp->checksum = ~ip_csum_fold (csum);
470 ip4_map_t_icmp (vlib_main_t * vm,
471 vlib_node_runtime_t * node, vlib_frame_t * frame)
473 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
474 vlib_node_runtime_t *error_node =
475 vlib_node_get_runtime (vm, ip4_map_t_icmp_node.index);
476 from = vlib_frame_vector_args (frame);
477 n_left_from = frame->n_vectors;
478 next_index = node->cached_next_index;
479 vlib_combined_counter_main_t *cm = map_main.domain_counters;
480 u32 cpu_index = os_get_cpu_number ();
482 while (n_left_from > 0)
484 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
486 while (n_left_from > 0 && n_left_to_next > 0)
490 ip4_mapt_icmp_next_t next0;
495 next0 = IP4_MAPT_ICMP_NEXT_IP6_LOOKUP;
496 pi0 = to_next[0] = from[0];
501 error0 = MAP_ERROR_NONE;
503 p0 = vlib_get_buffer (vm, pi0);
504 vlib_buffer_advance (p0, sizeof (ip4_mapt_pseudo_header_t)); //The pseudo-header is not used
506 clib_net_to_host_u16 (((ip4_header_t *)
507 vlib_buffer_get_current (p0))->length);
509 pool_elt_at_index (map_main.domains,
510 vnet_buffer (p0)->map_t.map_domain_index);
511 _ip4_map_t_icmp (d0, p0, &error0);
513 if (vnet_buffer (p0)->map_t.mtu < p0->current_length)
515 vnet_buffer (p0)->ip_frag.header_offset = 0;
516 vnet_buffer (p0)->ip_frag.mtu = vnet_buffer (p0)->map_t.mtu;
517 vnet_buffer (p0)->ip_frag.next_index = IP6_FRAG_NEXT_IP6_LOOKUP;
518 next0 = IP4_MAPT_ICMP_NEXT_IP6_FRAG;
520 if (PREDICT_TRUE (error0 == MAP_ERROR_NONE))
522 vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
524 vnet_buffer (p0)->map_t.
525 map_domain_index, 1, len0);
529 next0 = IP4_MAPT_ICMP_NEXT_DROP;
531 p0->error = error_node->errors[error0];
532 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
533 to_next, n_left_to_next, pi0,
536 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
538 return frame->n_vectors;
542 ip4_map_t_fragmented (vlib_main_t * vm,
543 vlib_node_runtime_t * node, vlib_frame_t * frame)
545 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
546 from = vlib_frame_vector_args (frame);
547 n_left_from = frame->n_vectors;
548 next_index = node->cached_next_index;
550 while (n_left_from > 0)
552 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
554 while (n_left_from > 0 && n_left_to_next > 0)
560 ip6_frag_hdr_t *frag0;
561 ip4_mapt_pseudo_header_t *pheader0;
562 ip4_mapt_fragmented_next_t next0;
564 next0 = IP4_MAPT_FRAGMENTED_NEXT_IP6_LOOKUP;
565 pi0 = to_next[0] = from[0];
571 p0 = vlib_get_buffer (vm, pi0);
573 //Accessing pseudo header
574 pheader0 = vlib_buffer_get_current (p0);
575 vlib_buffer_advance (p0, sizeof (*pheader0));
577 //Accessing ip4 header
578 ip40 = vlib_buffer_get_current (p0);
580 (ip6_frag_hdr_t *) u8_ptr_add (ip40,
581 sizeof (*ip40) - sizeof (*frag0));
583 (ip6_header_t *) u8_ptr_add (ip40,
584 sizeof (*ip40) - sizeof (*frag0) -
586 vlib_buffer_advance (p0,
587 sizeof (*ip40) - sizeof (*ip60) -
590 //We know that the protocol was one of ICMP, TCP or UDP
591 //because the first fragment was found and cached
594 IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 : ip40->protocol;
595 frag0->identification = frag_id_4to6 (ip40->fragment_id);
597 frag0->fragment_offset_and_more =
598 ip6_frag_hdr_offset_and_more (ip4_get_fragment_offset (ip40),
600 (ip40->flags_and_fragment_offset) &
601 IP4_HEADER_FLAG_MORE_FRAGMENTS);
603 ip60->ip_version_traffic_class_and_flow_label =
604 clib_host_to_net_u32 ((6 << 28) + (ip40->tos << 20));
605 ip60->payload_length =
606 clib_host_to_net_u16 (clib_net_to_host_u16 (ip40->length) -
607 sizeof (*ip40) + sizeof (*frag0));
608 ip60->hop_limit = ip40->ttl;
609 ip60->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
610 ip60->dst_address.as_u64[0] = pheader0->daddr.as_u64[0];
611 ip60->dst_address.as_u64[1] = pheader0->daddr.as_u64[1];
612 ip60->src_address.as_u64[0] = pheader0->saddr.as_u64[0];
613 ip60->src_address.as_u64[1] = pheader0->saddr.as_u64[1];
615 if (vnet_buffer (p0)->map_t.mtu < p0->current_length)
617 vnet_buffer (p0)->ip_frag.header_offset = 0;
618 vnet_buffer (p0)->ip_frag.mtu = vnet_buffer (p0)->map_t.mtu;
619 vnet_buffer (p0)->ip_frag.next_index = IP6_FRAG_NEXT_IP6_LOOKUP;
620 next0 = IP4_MAPT_FRAGMENTED_NEXT_IP6_FRAG;
623 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
624 to_next, n_left_to_next, pi0,
627 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
629 return frame->n_vectors;
633 ip4_map_t_tcp_udp (vlib_main_t * vm,
634 vlib_node_runtime_t * node, vlib_frame_t * frame)
636 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
637 from = vlib_frame_vector_args (frame);
638 n_left_from = frame->n_vectors;
639 next_index = node->cached_next_index;
641 while (n_left_from > 0)
643 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
645 #ifdef IP4_MAP_T_DUAL_LOOP
646 while (n_left_from >= 4 && n_left_to_next >= 2)
649 vlib_buffer_t *p0, *p1;
650 ip4_header_t *ip40, *ip41;
651 ip6_header_t *ip60, *ip61;
652 ip_csum_t csum0, csum1;
653 u16 *checksum0, *checksum1;
654 ip6_frag_hdr_t *frag0, *frag1;
655 u32 frag_id0, frag_id1;
656 ip4_mapt_pseudo_header_t *pheader0, *pheader1;
657 ip4_mapt_tcp_udp_next_t next0, next1;
659 pi0 = to_next[0] = from[0];
660 pi1 = to_next[1] = from[1];
666 next0 = IP4_MAPT_TCP_UDP_NEXT_IP6_LOOKUP;
667 next1 = IP4_MAPT_TCP_UDP_NEXT_IP6_LOOKUP;
668 p0 = vlib_get_buffer (vm, pi0);
669 p1 = vlib_get_buffer (vm, pi1);
671 //Accessing pseudo header
672 pheader0 = vlib_buffer_get_current (p0);
673 pheader1 = vlib_buffer_get_current (p1);
674 vlib_buffer_advance (p0, sizeof (*pheader0));
675 vlib_buffer_advance (p1, sizeof (*pheader1));
677 //Accessing ip4 header
678 ip40 = vlib_buffer_get_current (p0);
679 ip41 = vlib_buffer_get_current (p1);
681 (u16 *) u8_ptr_add (ip40,
682 vnet_buffer (p0)->map_t.checksum_offset);
684 (u16 *) u8_ptr_add (ip41,
685 vnet_buffer (p1)->map_t.checksum_offset);
687 //UDP checksum is optional over IPv4 but mandatory for IPv6
688 //We do not check udp->length sanity but use our safe computed value instead
690 (!*checksum0 && ip40->protocol == IP_PROTOCOL_UDP))
693 clib_host_to_net_u16 (ip40->length) - sizeof (*ip40);
695 (udp_header_t *) u8_ptr_add (ip40, sizeof (*ip40));
697 csum = ip_incremental_checksum (0, udp, udp_len);
699 ip_csum_with_carry (csum, clib_host_to_net_u16 (udp_len));
701 ip_csum_with_carry (csum,
702 clib_host_to_net_u16 (IP_PROTOCOL_UDP));
704 ip_csum_with_carry (csum, *((u64 *) (&ip40->src_address)));
705 *checksum0 = ~ip_csum_fold (csum);
708 (!*checksum1 && ip41->protocol == IP_PROTOCOL_UDP))
711 clib_host_to_net_u16 (ip41->length) - sizeof (*ip40);
713 (udp_header_t *) u8_ptr_add (ip41, sizeof (*ip40));
715 csum = ip_incremental_checksum (0, udp, udp_len);
717 ip_csum_with_carry (csum, clib_host_to_net_u16 (udp_len));
719 ip_csum_with_carry (csum,
720 clib_host_to_net_u16 (IP_PROTOCOL_UDP));
722 ip_csum_with_carry (csum, *((u64 *) (&ip41->src_address)));
723 *checksum1 = ~ip_csum_fold (csum);
726 csum0 = ip_csum_sub_even (*checksum0, ip40->src_address.as_u32);
727 csum1 = ip_csum_sub_even (*checksum1, ip41->src_address.as_u32);
728 csum0 = ip_csum_sub_even (csum0, ip40->dst_address.as_u32);
729 csum1 = ip_csum_sub_even (csum1, ip41->dst_address.as_u32);
731 // Deal with fragmented packets
732 if (PREDICT_FALSE (ip40->flags_and_fragment_offset &
734 (IP4_HEADER_FLAG_MORE_FRAGMENTS)))
737 (ip6_header_t *) u8_ptr_add (ip40,
738 sizeof (*ip40) - sizeof (*ip60) -
741 (ip6_frag_hdr_t *) u8_ptr_add (ip40,
744 frag_id0 = frag_id_4to6 (ip40->fragment_id);
745 vlib_buffer_advance (p0,
746 sizeof (*ip40) - sizeof (*ip60) -
752 (ip6_header_t *) (((u8 *) ip40) + sizeof (*ip40) -
754 vlib_buffer_advance (p0, sizeof (*ip40) - sizeof (*ip60));
758 if (PREDICT_FALSE (ip41->flags_and_fragment_offset &
760 (IP4_HEADER_FLAG_MORE_FRAGMENTS)))
763 (ip6_header_t *) u8_ptr_add (ip41,
764 sizeof (*ip40) - sizeof (*ip60) -
767 (ip6_frag_hdr_t *) u8_ptr_add (ip41,
770 frag_id1 = frag_id_4to6 (ip41->fragment_id);
771 vlib_buffer_advance (p1,
772 sizeof (*ip40) - sizeof (*ip60) -
778 (ip6_header_t *) (((u8 *) ip41) + sizeof (*ip40) -
780 vlib_buffer_advance (p1, sizeof (*ip40) - sizeof (*ip60));
784 ip60->ip_version_traffic_class_and_flow_label =
785 clib_host_to_net_u32 ((6 << 28) + (ip40->tos << 20));
786 ip61->ip_version_traffic_class_and_flow_label =
787 clib_host_to_net_u32 ((6 << 28) + (ip41->tos << 20));
788 ip60->payload_length = u16_net_add (ip40->length, -sizeof (*ip40));
789 ip61->payload_length = u16_net_add (ip41->length, -sizeof (*ip40));
790 ip60->hop_limit = ip40->ttl;
791 ip61->hop_limit = ip41->ttl;
792 ip60->protocol = ip40->protocol;
793 ip61->protocol = ip41->protocol;
795 if (PREDICT_FALSE (frag0 != NULL))
797 frag0->next_hdr = ip60->protocol;
798 frag0->identification = frag_id0;
800 frag0->fragment_offset_and_more =
801 ip6_frag_hdr_offset_and_more (0, 1);
802 ip60->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
803 ip60->payload_length =
804 u16_net_add (ip60->payload_length, sizeof (*frag0));
807 if (PREDICT_FALSE (frag1 != NULL))
809 frag1->next_hdr = ip61->protocol;
810 frag1->identification = frag_id1;
812 frag1->fragment_offset_and_more =
813 ip6_frag_hdr_offset_and_more (0, 1);
814 ip61->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
815 ip61->payload_length =
816 u16_net_add (ip61->payload_length, sizeof (*frag0));
819 //Finally copying the address
820 ip60->dst_address.as_u64[0] = pheader0->daddr.as_u64[0];
821 ip61->dst_address.as_u64[0] = pheader1->daddr.as_u64[0];
822 ip60->dst_address.as_u64[1] = pheader0->daddr.as_u64[1];
823 ip61->dst_address.as_u64[1] = pheader1->daddr.as_u64[1];
824 ip60->src_address.as_u64[0] = pheader0->saddr.as_u64[0];
825 ip61->src_address.as_u64[0] = pheader1->saddr.as_u64[0];
826 ip60->src_address.as_u64[1] = pheader0->saddr.as_u64[1];
827 ip61->src_address.as_u64[1] = pheader1->saddr.as_u64[1];
829 csum0 = ip_csum_add_even (csum0, ip60->src_address.as_u64[0]);
830 csum1 = ip_csum_add_even (csum1, ip61->src_address.as_u64[0]);
831 csum0 = ip_csum_add_even (csum0, ip60->src_address.as_u64[1]);
832 csum1 = ip_csum_add_even (csum1, ip61->src_address.as_u64[1]);
833 csum0 = ip_csum_add_even (csum0, ip60->dst_address.as_u64[0]);
834 csum1 = ip_csum_add_even (csum1, ip61->dst_address.as_u64[0]);
835 csum0 = ip_csum_add_even (csum0, ip60->dst_address.as_u64[1]);
836 csum1 = ip_csum_add_even (csum1, ip61->dst_address.as_u64[1]);
837 *checksum0 = ip_csum_fold (csum0);
838 *checksum1 = ip_csum_fold (csum1);
840 if (vnet_buffer (p0)->map_t.mtu < p0->current_length)
842 vnet_buffer (p0)->ip_frag.header_offset = 0;
843 vnet_buffer (p0)->ip_frag.mtu = vnet_buffer (p0)->map_t.mtu;
844 vnet_buffer (p0)->ip_frag.next_index = IP6_FRAG_NEXT_IP6_LOOKUP;
845 next0 = IP4_MAPT_TCP_UDP_NEXT_IP6_FRAG;
848 if (vnet_buffer (p1)->map_t.mtu < p1->current_length)
850 vnet_buffer (p1)->ip_frag.header_offset = 0;
851 vnet_buffer (p1)->ip_frag.mtu = vnet_buffer (p1)->map_t.mtu;
852 vnet_buffer (p1)->ip_frag.next_index = IP6_FRAG_NEXT_IP6_LOOKUP;
853 next1 = IP4_MAPT_TCP_UDP_NEXT_IP6_FRAG;
856 vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
857 to_next, n_left_to_next, pi0, pi1,
862 while (n_left_from > 0 && n_left_to_next > 0)
870 ip6_frag_hdr_t *frag0;
872 ip4_mapt_pseudo_header_t *pheader0;
873 ip4_mapt_tcp_udp_next_t next0;
875 pi0 = to_next[0] = from[0];
881 next0 = IP4_MAPT_TCP_UDP_NEXT_IP6_LOOKUP;
882 p0 = vlib_get_buffer (vm, pi0);
884 //Accessing pseudo header
885 pheader0 = vlib_buffer_get_current (p0);
886 vlib_buffer_advance (p0, sizeof (*pheader0));
888 //Accessing ip4 header
889 ip40 = vlib_buffer_get_current (p0);
891 (u16 *) u8_ptr_add (ip40,
892 vnet_buffer (p0)->map_t.checksum_offset);
894 //UDP checksum is optional over IPv4 but mandatory for IPv6
895 //We do not check udp->length sanity but use our safe computed value instead
897 (!*checksum0 && ip40->protocol == IP_PROTOCOL_UDP))
900 clib_host_to_net_u16 (ip40->length) - sizeof (*ip40);
902 (udp_header_t *) u8_ptr_add (ip40, sizeof (*ip40));
904 csum = ip_incremental_checksum (0, udp, udp_len);
906 ip_csum_with_carry (csum, clib_host_to_net_u16 (udp_len));
908 ip_csum_with_carry (csum,
909 clib_host_to_net_u16 (IP_PROTOCOL_UDP));
911 ip_csum_with_carry (csum, *((u64 *) (&ip40->src_address)));
912 *checksum0 = ~ip_csum_fold (csum);
915 csum0 = ip_csum_sub_even (*checksum0, ip40->src_address.as_u32);
916 csum0 = ip_csum_sub_even (csum0, ip40->dst_address.as_u32);
918 // Deal with fragmented packets
919 if (PREDICT_FALSE (ip40->flags_and_fragment_offset &
921 (IP4_HEADER_FLAG_MORE_FRAGMENTS)))
924 (ip6_header_t *) u8_ptr_add (ip40,
925 sizeof (*ip40) - sizeof (*ip60) -
928 (ip6_frag_hdr_t *) u8_ptr_add (ip40,
931 frag_id0 = frag_id_4to6 (ip40->fragment_id);
932 vlib_buffer_advance (p0,
933 sizeof (*ip40) - sizeof (*ip60) -
939 (ip6_header_t *) (((u8 *) ip40) + sizeof (*ip40) -
941 vlib_buffer_advance (p0, sizeof (*ip40) - sizeof (*ip60));
945 ip60->ip_version_traffic_class_and_flow_label =
946 clib_host_to_net_u32 ((6 << 28) + (ip40->tos << 20));
947 ip60->payload_length = u16_net_add (ip40->length, -sizeof (*ip40));
948 ip60->hop_limit = ip40->ttl;
949 ip60->protocol = ip40->protocol;
951 if (PREDICT_FALSE (frag0 != NULL))
953 frag0->next_hdr = ip60->protocol;
954 frag0->identification = frag_id0;
956 frag0->fragment_offset_and_more =
957 ip6_frag_hdr_offset_and_more (0, 1);
958 ip60->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
959 ip60->payload_length =
960 u16_net_add (ip60->payload_length, sizeof (*frag0));
963 //Finally copying the address
964 ip60->dst_address.as_u64[0] = pheader0->daddr.as_u64[0];
965 ip60->dst_address.as_u64[1] = pheader0->daddr.as_u64[1];
966 ip60->src_address.as_u64[0] = pheader0->saddr.as_u64[0];
967 ip60->src_address.as_u64[1] = pheader0->saddr.as_u64[1];
969 csum0 = ip_csum_add_even (csum0, ip60->src_address.as_u64[0]);
970 csum0 = ip_csum_add_even (csum0, ip60->src_address.as_u64[1]);
971 csum0 = ip_csum_add_even (csum0, ip60->dst_address.as_u64[0]);
972 csum0 = ip_csum_add_even (csum0, ip60->dst_address.as_u64[1]);
973 *checksum0 = ip_csum_fold (csum0);
975 if (vnet_buffer (p0)->map_t.mtu < p0->current_length)
977 //Send to fragmentation node if necessary
978 vnet_buffer (p0)->ip_frag.header_offset = 0;
979 vnet_buffer (p0)->ip_frag.mtu = vnet_buffer (p0)->map_t.mtu;
980 vnet_buffer (p0)->ip_frag.next_index = IP6_FRAG_NEXT_IP6_LOOKUP;
981 next0 = IP4_MAPT_TCP_UDP_NEXT_IP6_FRAG;
984 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
985 to_next, n_left_to_next, pi0,
988 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
991 return frame->n_vectors;
994 static_always_inline void
995 ip4_map_t_classify (vlib_buffer_t * p0, map_domain_t * d0,
996 ip4_header_t * ip40, u16 ip4_len0, i32 * dst_port0,
997 u8 * error0, ip4_mapt_next_t * next0)
999 if (PREDICT_FALSE (ip4_get_fragment_offset (ip40)))
1001 *next0 = IP4_MAPT_NEXT_MAPT_FRAGMENTED;
1002 if (d0->ea_bits_len == 0 && d0->rules)
1008 *dst_port0 = ip4_map_fragment_get_port (ip40);
1009 *error0 = (*dst_port0 == -1) ? MAP_ERROR_FRAGMENT_MEMORY : *error0;
1012 else if (PREDICT_TRUE (ip40->protocol == IP_PROTOCOL_TCP))
1014 vnet_buffer (p0)->map_t.checksum_offset = 36;
1015 *next0 = IP4_MAPT_NEXT_MAPT_TCP_UDP;
1016 *error0 = ip4_len0 < 40 ? MAP_ERROR_MALFORMED : *error0;
1017 *dst_port0 = (i32) * ((u16 *) u8_ptr_add (ip40, sizeof (*ip40) + 2));
1019 else if (PREDICT_TRUE (ip40->protocol == IP_PROTOCOL_UDP))
1021 vnet_buffer (p0)->map_t.checksum_offset = 26;
1022 *next0 = IP4_MAPT_NEXT_MAPT_TCP_UDP;
1023 *error0 = ip4_len0 < 28 ? MAP_ERROR_MALFORMED : *error0;
1024 *dst_port0 = (i32) * ((u16 *) u8_ptr_add (ip40, sizeof (*ip40) + 2));
1026 else if (ip40->protocol == IP_PROTOCOL_ICMP)
1028 *next0 = IP4_MAPT_NEXT_MAPT_ICMP;
1029 if (d0->ea_bits_len == 0 && d0->rules)
1031 else if (((icmp46_header_t *) u8_ptr_add (ip40, sizeof (*ip40)))->code
1033 || ((icmp46_header_t *)
1035 sizeof (*ip40)))->code == ICMP4_echo_request)
1036 *dst_port0 = (i32) * ((u16 *) u8_ptr_add (ip40, sizeof (*ip40) + 6));
1040 *error0 = MAP_ERROR_BAD_PROTOCOL;
1045 ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
1047 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
1048 vlib_node_runtime_t *error_node =
1049 vlib_node_get_runtime (vm, ip4_map_t_node.index);
1050 from = vlib_frame_vector_args (frame);
1051 n_left_from = frame->n_vectors;
1052 next_index = node->cached_next_index;
1053 vlib_combined_counter_main_t *cm = map_main.domain_counters;
1054 u32 cpu_index = os_get_cpu_number ();
1056 while (n_left_from > 0)
1058 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1060 #ifdef IP4_MAP_T_DUAL_LOOP
1061 while (n_left_from >= 4 && n_left_to_next >= 2)
1064 vlib_buffer_t *p0, *p1;
1065 ip4_header_t *ip40, *ip41;
1066 map_domain_t *d0, *d1;
1067 ip4_mapt_next_t next0 = 0, next1 = 0;
1068 u16 ip4_len0, ip4_len1;
1070 i32 dst_port0, dst_port1;
1071 ip4_mapt_pseudo_header_t *pheader0, *pheader1;
1073 pi0 = to_next[0] = from[0];
1074 pi1 = to_next[1] = from[1];
1078 n_left_to_next -= 2;
1079 error0 = MAP_ERROR_NONE;
1080 error1 = MAP_ERROR_NONE;
1082 p0 = vlib_get_buffer (vm, pi0);
1083 p1 = vlib_get_buffer (vm, pi1);
1084 ip40 = vlib_buffer_get_current (p0);
1085 ip41 = vlib_buffer_get_current (p1);
1086 ip4_len0 = clib_host_to_net_u16 (ip40->length);
1087 ip4_len1 = clib_host_to_net_u16 (ip41->length);
1089 if (PREDICT_FALSE (p0->current_length < ip4_len0 ||
1090 ip40->ip_version_and_header_length != 0x45))
1092 error0 = MAP_ERROR_UNKNOWN;
1093 next0 = IP4_MAPT_NEXT_DROP;
1096 if (PREDICT_FALSE (p1->current_length < ip4_len1 ||
1097 ip41->ip_version_and_header_length != 0x45))
1099 error1 = MAP_ERROR_UNKNOWN;
1100 next1 = IP4_MAPT_NEXT_DROP;
1103 d0 = ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
1104 &vnet_buffer (p0)->map_t.map_domain_index);
1105 d1 = ip4_map_get_domain (vnet_buffer (p1)->ip.adj_index[VLIB_TX],
1106 &vnet_buffer (p1)->map_t.map_domain_index);
1108 vnet_buffer (p0)->map_t.mtu = d0->mtu ? d0->mtu : ~0;
1109 vnet_buffer (p1)->map_t.mtu = d1->mtu ? d1->mtu : ~0;
1114 ip4_map_t_classify (p0, d0, ip40, ip4_len0, &dst_port0, &error0,
1116 ip4_map_t_classify (p1, d1, ip41, ip4_len1, &dst_port1, &error1,
1119 //Add MAP-T pseudo header in front of the packet
1120 vlib_buffer_advance (p0, -sizeof (*pheader0));
1121 vlib_buffer_advance (p1, -sizeof (*pheader1));
1122 pheader0 = vlib_buffer_get_current (p0);
1123 pheader1 = vlib_buffer_get_current (p1);
1125 //Save addresses within the packet
1126 ip4_map_t_embedded_address (d0, &pheader0->saddr,
1127 &ip40->src_address);
1128 ip4_map_t_embedded_address (d1, &pheader1->saddr,
1129 &ip41->src_address);
1130 pheader0->daddr.as_u64[0] =
1131 map_get_pfx_net (d0, ip40->dst_address.as_u32, (u16) dst_port0);
1132 pheader0->daddr.as_u64[1] =
1133 map_get_sfx_net (d0, ip40->dst_address.as_u32, (u16) dst_port0);
1134 pheader1->daddr.as_u64[0] =
1135 map_get_pfx_net (d1, ip41->dst_address.as_u32, (u16) dst_port1);
1136 pheader1->daddr.as_u64[1] =
1137 map_get_sfx_net (d1, ip41->dst_address.as_u32, (u16) dst_port1);
1140 (ip4_is_first_fragment (ip40) && (dst_port0 != -1)
1141 && (d0->ea_bits_len != 0 || !d0->rules)
1142 && ip4_map_fragment_cache (ip40, dst_port0)))
1144 error0 = MAP_ERROR_FRAGMENT_MEMORY;
1148 (ip4_is_first_fragment (ip41) && (dst_port1 != -1)
1149 && (d1->ea_bits_len != 0 || !d1->rules)
1150 && ip4_map_fragment_cache (ip41, dst_port1)))
1152 error1 = MAP_ERROR_FRAGMENT_MEMORY;
1156 (error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP))
1158 vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
1160 vnet_buffer (p0)->map_t.
1161 map_domain_index, 1,
1162 clib_net_to_host_u16 (ip40->
1167 (error1 == MAP_ERROR_NONE && next1 != IP4_MAPT_NEXT_MAPT_ICMP))
1169 vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
1171 vnet_buffer (p1)->map_t.
1172 map_domain_index, 1,
1173 clib_net_to_host_u16 (ip41->
1177 next0 = (error0 != MAP_ERROR_NONE) ? IP4_MAPT_NEXT_DROP : next0;
1178 next1 = (error1 != MAP_ERROR_NONE) ? IP4_MAPT_NEXT_DROP : next1;
1179 p0->error = error_node->errors[error0];
1180 p1->error = error_node->errors[error1];
1181 vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
1182 n_left_to_next, pi0, pi1, next0,
1187 while (n_left_from > 0 && n_left_to_next > 0)
1193 ip4_mapt_next_t next0;
1197 ip4_mapt_pseudo_header_t *pheader0;
1199 pi0 = to_next[0] = from[0];
1203 n_left_to_next -= 1;
1204 error0 = MAP_ERROR_NONE;
1206 p0 = vlib_get_buffer (vm, pi0);
1207 ip40 = vlib_buffer_get_current (p0);
1208 ip4_len0 = clib_host_to_net_u16 (ip40->length);
1209 if (PREDICT_FALSE (p0->current_length < ip4_len0 ||
1210 ip40->ip_version_and_header_length != 0x45))
1212 error0 = MAP_ERROR_UNKNOWN;
1213 next0 = IP4_MAPT_NEXT_DROP;
1216 d0 = ip4_map_get_domain (vnet_buffer (p0)->ip.adj_index[VLIB_TX],
1217 &vnet_buffer (p0)->map_t.map_domain_index);
1219 vnet_buffer (p0)->map_t.mtu = d0->mtu ? d0->mtu : ~0;
1222 ip4_map_t_classify (p0, d0, ip40, ip4_len0, &dst_port0, &error0,
1225 //Add MAP-T pseudo header in front of the packet
1226 vlib_buffer_advance (p0, -sizeof (*pheader0));
1227 pheader0 = vlib_buffer_get_current (p0);
1229 //Save addresses within the packet
1230 ip4_map_t_embedded_address (d0, &pheader0->saddr,
1231 &ip40->src_address);
1232 pheader0->daddr.as_u64[0] =
1233 map_get_pfx_net (d0, ip40->dst_address.as_u32, (u16) dst_port0);
1234 pheader0->daddr.as_u64[1] =
1235 map_get_sfx_net (d0, ip40->dst_address.as_u32, (u16) dst_port0);
1237 //It is important to cache at this stage because the result might be necessary
1238 //for packets within the same vector.
1239 //Actually, this approach even provides some limited out-of-order fragments support
1241 (ip4_is_first_fragment (ip40) && (dst_port0 != -1)
1242 && (d0->ea_bits_len != 0 || !d0->rules)
1243 && ip4_map_fragment_cache (ip40, dst_port0)))
1245 error0 = MAP_ERROR_UNKNOWN;
1249 (error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP))
1251 vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
1253 vnet_buffer (p0)->map_t.
1254 map_domain_index, 1,
1255 clib_net_to_host_u16 (ip40->
1259 next0 = (error0 != MAP_ERROR_NONE) ? IP4_MAPT_NEXT_DROP : next0;
1260 p0->error = error_node->errors[error0];
1261 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
1262 to_next, n_left_to_next, pi0,
1265 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1267 return frame->n_vectors;
1270 static char *map_t_error_strings[] = {
1271 #define _(sym,string) string,
1277 VLIB_REGISTER_NODE(ip4_map_t_fragmented_node) = {
1278 .function = ip4_map_t_fragmented,
1279 .name = "ip4-map-t-fragmented",
1280 .vector_size = sizeof(u32),
1281 .format_trace = format_map_trace,
1282 .type = VLIB_NODE_TYPE_INTERNAL,
1284 .n_errors = MAP_N_ERROR,
1285 .error_strings = map_t_error_strings,
1287 .n_next_nodes = IP4_MAPT_FRAGMENTED_N_NEXT,
1289 [IP4_MAPT_FRAGMENTED_NEXT_IP6_LOOKUP] = "ip6-lookup",
1290 [IP4_MAPT_FRAGMENTED_NEXT_IP6_FRAG] = IP6_FRAG_NODE_NAME,
1291 [IP4_MAPT_FRAGMENTED_NEXT_DROP] = "error-drop",
1297 VLIB_REGISTER_NODE(ip4_map_t_icmp_node) = {
1298 .function = ip4_map_t_icmp,
1299 .name = "ip4-map-t-icmp",
1300 .vector_size = sizeof(u32),
1301 .format_trace = format_map_trace,
1302 .type = VLIB_NODE_TYPE_INTERNAL,
1304 .n_errors = MAP_N_ERROR,
1305 .error_strings = map_t_error_strings,
1307 .n_next_nodes = IP4_MAPT_ICMP_N_NEXT,
1309 [IP4_MAPT_ICMP_NEXT_IP6_LOOKUP] = "ip6-lookup",
1310 [IP4_MAPT_ICMP_NEXT_IP6_FRAG] = IP6_FRAG_NODE_NAME,
1311 [IP4_MAPT_ICMP_NEXT_DROP] = "error-drop",
1317 VLIB_REGISTER_NODE(ip4_map_t_tcp_udp_node) = {
1318 .function = ip4_map_t_tcp_udp,
1319 .name = "ip4-map-t-tcp-udp",
1320 .vector_size = sizeof(u32),
1321 .format_trace = format_map_trace,
1322 .type = VLIB_NODE_TYPE_INTERNAL,
1324 .n_errors = MAP_N_ERROR,
1325 .error_strings = map_t_error_strings,
1327 .n_next_nodes = IP4_MAPT_TCP_UDP_N_NEXT,
1329 [IP4_MAPT_TCP_UDP_NEXT_IP6_LOOKUP] = "ip6-lookup",
1330 [IP4_MAPT_TCP_UDP_NEXT_IP6_FRAG] = IP6_FRAG_NODE_NAME,
1331 [IP4_MAPT_TCP_UDP_NEXT_DROP] = "error-drop",
1337 VLIB_REGISTER_NODE(ip4_map_t_node) = {
1338 .function = ip4_map_t,
1339 .name = "ip4-map-t",
1340 .vector_size = sizeof(u32),
1341 .format_trace = format_map_trace,
1342 .type = VLIB_NODE_TYPE_INTERNAL,
1344 .n_errors = MAP_N_ERROR,
1345 .error_strings = map_t_error_strings,
1347 .n_next_nodes = IP4_MAPT_N_NEXT,
1349 [IP4_MAPT_NEXT_MAPT_TCP_UDP] = "ip4-map-t-tcp-udp",
1350 [IP4_MAPT_NEXT_MAPT_ICMP] = "ip4-map-t-icmp",
1351 [IP4_MAPT_NEXT_MAPT_FRAGMENTED] = "ip4-map-t-fragmented",
1352 [IP4_MAPT_NEXT_DROP] = "error-drop",
1358 * fd.io coding-style-patch-verification: ON
1361 * eval: (c-set-style "gnu")