2 * Copyright (c) 2017 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.
20 #include <nat/nat64.h>
22 #include <vnet/fib/fib_table.h>
25 nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
26 unformat_input_t * input,
27 vlib_cli_command_t * cmd)
29 unformat_input_t _line_input, *line_input = &_line_input;
30 ip4_address_t start_addr, end_addr, this_addr;
31 u32 start_host_order, end_host_order;
35 clib_error_t *error = 0;
37 /* Get a line of input. */
38 if (!unformat_user (input, unformat_line_input, line_input))
41 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
43 if (unformat (line_input, "%U - %U",
44 unformat_ip4_address, &start_addr,
45 unformat_ip4_address, &end_addr))
47 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
49 else if (unformat (line_input, "%U", unformat_ip4_address, &start_addr))
50 end_addr = start_addr;
51 else if (unformat (line_input, "del"))
55 error = clib_error_return (0, "unknown input '%U'",
56 format_unformat_error, line_input);
61 start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
62 end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
64 if (end_host_order < start_host_order)
66 error = clib_error_return (0, "end address less than start address");
70 count = (end_host_order - start_host_order) + 1;
71 this_addr = start_addr;
73 for (i = 0; i < count; i++)
75 rv = nat64_add_del_pool_addr (&this_addr, vrf_id, is_add);
79 case VNET_API_ERROR_NO_SUCH_ENTRY:
81 clib_error_return (0, "NAT64 pool address %U not exist.",
82 format_ip4_address, &this_addr);
84 case VNET_API_ERROR_VALUE_EXIST:
86 clib_error_return (0, "NAT64 pool address %U exist.",
87 format_ip4_address, &this_addr);
93 increment_v4_address (&this_addr);
97 unformat_free (line_input);
103 nat64_cli_pool_walk (snat_address_t * ap, void *ctx)
105 vlib_main_t *vm = ctx;
107 if (ap->fib_index != ~0)
110 fib = fib_table_get (ap->fib_index, FIB_PROTOCOL_IP6);
113 vlib_cli_output (vm, " %U tenant VRF: %u", format_ip4_address,
114 &ap->addr, fib->ft_table_id);
117 vlib_cli_output (vm, " %U", format_ip4_address, &ap->addr);
119 #define _(N, i, n, s) \
120 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
121 foreach_snat_protocol
126 static clib_error_t *
127 nat64_show_pool_command_fn (vlib_main_t * vm,
128 unformat_input_t * input,
129 vlib_cli_command_t * cmd)
131 vlib_cli_output (vm, "NAT64 pool:");
132 nat64_pool_addr_walk (nat64_cli_pool_walk, vm);
137 static clib_error_t *
138 nat64_interface_feature_command_fn (vlib_main_t * vm,
140 input, vlib_cli_command_t * cmd)
142 unformat_input_t _line_input, *line_input = &_line_input;
143 vnet_main_t *vnm = vnet_get_main ();
144 clib_error_t *error = 0;
146 u32 *inside_sw_if_indices = 0;
147 u32 *outside_sw_if_indices = 0;
151 /* Get a line of input. */
152 if (!unformat_user (input, unformat_line_input, line_input))
155 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
157 if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
159 vec_add1 (inside_sw_if_indices, sw_if_index);
160 else if (unformat (line_input, "out %U", unformat_vnet_sw_interface,
162 vec_add1 (outside_sw_if_indices, sw_if_index);
163 else if (unformat (line_input, "del"))
167 error = clib_error_return (0, "unknown input '%U'",
168 format_unformat_error, line_input);
173 if (vec_len (inside_sw_if_indices))
175 for (i = 0; i < vec_len (inside_sw_if_indices); i++)
177 sw_if_index = inside_sw_if_indices[i];
178 rv = nat64_add_del_interface (sw_if_index, 1, is_add);
181 case VNET_API_ERROR_NO_SUCH_ENTRY:
183 clib_error_return (0, "%U NAT64 feature not enabled.",
184 format_vnet_sw_if_index_name, vnm,
187 case VNET_API_ERROR_VALUE_EXIST:
189 clib_error_return (0, "%U NAT64 feature already enabled.",
190 format_vnet_sw_if_index_name, vnm,
193 case VNET_API_ERROR_INVALID_VALUE:
194 case VNET_API_ERROR_INVALID_VALUE_2:
196 clib_error_return (0,
197 "%U NAT64 feature enable/disable failed.",
198 format_vnet_sw_if_index_name, vnm,
208 if (vec_len (outside_sw_if_indices))
210 for (i = 0; i < vec_len (outside_sw_if_indices); i++)
212 sw_if_index = outside_sw_if_indices[i];
213 rv = nat64_add_del_interface (sw_if_index, 0, is_add);
216 case VNET_API_ERROR_NO_SUCH_ENTRY:
218 clib_error_return (0, "%U NAT64 feature not enabled.",
219 format_vnet_sw_if_index_name, vnm,
222 case VNET_API_ERROR_VALUE_EXIST:
224 clib_error_return (0, "%U NAT64 feature already enabled.",
225 format_vnet_sw_if_index_name, vnm,
228 case VNET_API_ERROR_INVALID_VALUE:
229 case VNET_API_ERROR_INVALID_VALUE_2:
231 clib_error_return (0,
232 "%U NAT64 feature enable/disable failed.",
233 format_vnet_sw_if_index_name, vnm,
244 unformat_free (line_input);
245 vec_free (inside_sw_if_indices);
246 vec_free (outside_sw_if_indices);
252 nat64_cli_interface_walk (snat_interface_t * i, void *ctx)
254 vlib_main_t *vm = ctx;
255 vnet_main_t *vnm = vnet_get_main ();
257 vlib_cli_output (vm, " %U %s", format_vnet_sw_if_index_name, vnm,
259 (nat_interface_is_inside (i)
260 && nat_interface_is_outside (i)) ? "in out" :
261 nat_interface_is_inside (i) ? "in" : "out");
265 static clib_error_t *
266 nat64_show_interfaces_command_fn (vlib_main_t * vm,
268 input, vlib_cli_command_t * cmd)
270 vlib_cli_output (vm, "NAT64 interfaces:");
271 nat64_interfaces_walk (nat64_cli_interface_walk, vm);
276 static clib_error_t *
277 nat64_add_del_static_bib_command_fn (vlib_main_t *
280 * input, vlib_cli_command_t * cmd)
282 unformat_input_t _line_input, *line_input = &_line_input;
283 clib_error_t *error = 0;
285 ip6_address_t in_addr;
286 ip4_address_t out_addr;
289 u32 vrf_id = 0, protocol;
290 snat_protocol_t proto = 0;
294 if (!unformat_user (input, unformat_line_input, line_input))
297 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
299 if (unformat (line_input, "%U %u", unformat_ip6_address,
302 else if (unformat (line_input, "%U %u", unformat_ip4_address,
303 &out_addr, &out_port))
305 else if (unformat (line_input, "vrf %u", &vrf_id))
307 else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
311 (line_input, "%U %U %u", unformat_ip6_address, &in_addr,
312 unformat_ip4_address, &out_addr, &protocol))
314 else if (unformat (line_input, "del"))
318 error = clib_error_return (0, "unknown input: '%U'",
319 format_unformat_error, line_input);
329 clib_error_return (0, "inside port and address must be set");
336 clib_error_return (0, "outside port and address must be set");
340 p = snat_proto_to_ip_proto (proto);
344 nat64_add_del_static_bib_entry (&in_addr, &out_addr, (u16) in_port,
345 (u16) out_port, p, vrf_id, is_add);
349 case VNET_API_ERROR_NO_SUCH_ENTRY:
350 error = clib_error_return (0, "NAT64 BIB entry not exist.");
352 case VNET_API_ERROR_VALUE_EXIST:
353 error = clib_error_return (0, "NAT64 BIB entry exist.");
355 case VNET_API_ERROR_UNSPECIFIED:
356 error = clib_error_return (0, "Crerate NAT64 BIB entry failed.");
358 case VNET_API_ERROR_INVALID_VALUE:
360 clib_error_return (0, "Outside addres %U and port %u already in use.",
361 format_ip4_address, &out_addr, out_port);
363 case VNET_API_ERROR_INVALID_VALUE_2:
364 error = clib_error_return (0, "Invalid outside port.");
370 unformat_free (line_input);
376 nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
378 vlib_main_t *vm = ctx;
381 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
387 case IP_PROTOCOL_ICMP:
388 case IP_PROTOCOL_TCP:
389 case IP_PROTOCOL_UDP:
390 vlib_cli_output (vm, " %U %u %U %u protocol %U vrf %u %s %u sessions",
391 format_ip6_address, &bibe->in_addr,
392 clib_net_to_host_u16 (bibe->in_port),
393 format_ip4_address, &bibe->out_addr,
394 clib_net_to_host_u16 (bibe->out_port),
395 format_snat_protocol,
396 ip_proto_to_snat_proto (bibe->proto), fib->ft_table_id,
397 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
400 vlib_cli_output (vm, " %U %U protocol %u vrf %u %s %u sessions",
401 format_ip6_address, &bibe->in_addr,
402 format_ip4_address, &bibe->out_addr,
403 bibe->proto, fib->ft_table_id,
404 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
409 static clib_error_t *
410 nat64_show_bib_command_fn (vlib_main_t * vm,
411 unformat_input_t * input, vlib_cli_command_t * cmd)
413 nat64_main_t *nm = &nat64_main;
414 unformat_input_t _line_input, *line_input = &_line_input;
415 clib_error_t *error = 0;
420 if (!unformat_user (input, unformat_line_input, line_input))
423 if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
424 p = snat_proto_to_ip_proto (proto);
425 else if (unformat (line_input, "unknown"))
427 else if (unformat (line_input, "all"))
431 error = clib_error_return (0, "unknown input: '%U'",
432 format_unformat_error, line_input);
437 vlib_cli_output (vm, "NAT64 BIB entries:");
439 vlib_cli_output (vm, "NAT64 %U BIB entries:", format_snat_protocol,
443 vec_foreach (db, nm->db)
444 nat64_db_bib_walk (db, p, nat64_cli_bib_walk, vm);
448 unformat_free (line_input);
453 static clib_error_t *
454 nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
455 vlib_cli_command_t * cmd)
457 unformat_input_t _line_input, *line_input = &_line_input;
458 clib_error_t *error = 0;
459 u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
461 tcp_trans = nat64_get_tcp_trans_timeout ();
462 tcp_est = nat64_get_tcp_est_timeout ();
463 tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout ();
465 if (!unformat_user (input, unformat_line_input, line_input))
468 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
470 if (unformat (line_input, "udp %u", &timeout))
472 if (nat64_set_udp_timeout (timeout))
474 error = clib_error_return (0, "Invalid UDP timeout value");
478 else if (unformat (line_input, "icmp %u", &timeout))
480 if (nat64_set_icmp_timeout (timeout))
482 error = clib_error_return (0, "Invalid ICMP timeout value");
486 else if (unformat (line_input, "tcp-trans %u", &tcp_trans))
488 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
491 clib_error_return (0,
492 "Invalid TCP transitory timeouts value");
496 else if (unformat (line_input, "tcp-est %u", &tcp_est))
498 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
501 clib_error_return (0,
502 "Invalid TCP established timeouts value");
507 if (unformat (line_input, "tcp-incoming-syn %u", &tcp_incoming_syn))
509 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
512 clib_error_return (0,
513 "Invalid TCP incoming SYN timeouts value");
517 else if (unformat (line_input, "reset"))
519 nat64_set_udp_timeout (0);
520 nat64_set_icmp_timeout (0);
521 nat64_set_tcp_timeouts (0, 0, 0);
525 error = clib_error_return (0, "unknown input '%U'",
526 format_unformat_error, line_input);
532 unformat_free (line_input);
537 static clib_error_t *
538 nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
539 vlib_cli_command_t * cmd)
541 vlib_cli_output (vm, "NAT64 session timeouts:");
542 vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ());
543 vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ());
544 vlib_cli_output (vm, " TCP transitory %usec",
545 nat64_get_tcp_trans_timeout ());
546 vlib_cli_output (vm, " TCP established %usec",
547 nat64_get_tcp_est_timeout ());
548 vlib_cli_output (vm, " TCP incoming SYN %usec",
549 nat64_get_tcp_incoming_syn_timeout ());
554 typedef struct nat64_cli_st_walk_ctx_t_
558 } nat64_cli_st_walk_ctx_t;
561 nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *arg)
563 nat64_cli_st_walk_ctx_t *ctx = arg;
564 vlib_main_t *vm = ctx->vm;
565 nat64_db_bib_entry_t *bibe;
568 bibe = nat64_db_bib_entry_by_index (ctx->db, ste->proto, ste->bibe_index);
572 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
576 u32 vrf_id = fib->ft_table_id;
578 if (ste->proto == IP_PROTOCOL_ICMP)
579 vlib_cli_output (vm, " %U %U %u %U %U %u protocol %U vrf %u",
580 format_ip6_address, &bibe->in_addr,
581 format_ip6_address, &ste->in_r_addr,
582 clib_net_to_host_u16 (bibe->in_port),
583 format_ip4_address, &bibe->out_addr,
584 format_ip4_address, &ste->out_r_addr,
585 clib_net_to_host_u16 (bibe->out_port),
586 format_snat_protocol,
587 ip_proto_to_snat_proto (bibe->proto), vrf_id);
588 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
589 vlib_cli_output (vm, " %U %u %U %u %U %u %U %u protcol %U vrf %u",
590 format_ip6_address, &bibe->in_addr,
591 clib_net_to_host_u16 (bibe->in_port),
592 format_ip6_address, &ste->in_r_addr,
593 clib_net_to_host_u16 (ste->r_port),
594 format_ip4_address, &bibe->out_addr,
595 clib_net_to_host_u16 (bibe->out_port),
596 format_ip4_address, &ste->out_r_addr,
597 clib_net_to_host_u16 (ste->r_port),
598 format_snat_protocol,
599 ip_proto_to_snat_proto (bibe->proto), vrf_id);
601 vlib_cli_output (vm, " %U %U %U %U protocol %u vrf %u",
602 format_ip6_address, &bibe->in_addr,
603 format_ip6_address, &ste->in_r_addr,
604 format_ip4_address, &bibe->out_addr,
605 format_ip4_address, &ste->out_r_addr,
606 bibe->proto, vrf_id);
611 static clib_error_t *
612 nat64_show_st_command_fn (vlib_main_t * vm,
613 unformat_input_t * input, vlib_cli_command_t * cmd)
615 nat64_main_t *nm = &nat64_main;
616 unformat_input_t _line_input, *line_input = &_line_input;
617 clib_error_t *error = 0;
621 nat64_cli_st_walk_ctx_t ctx = {
625 if (!unformat_user (input, unformat_line_input, line_input))
628 if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
629 p = snat_proto_to_ip_proto (proto);
630 else if (unformat (line_input, "unknown"))
632 else if (unformat (line_input, "all"))
636 error = clib_error_return (0, "unknown input: '%U'",
637 format_unformat_error, line_input);
642 vlib_cli_output (vm, "NAT64 sessions:");
644 vlib_cli_output (vm, "NAT64 %U sessions:", format_snat_protocol, proto);
646 vec_foreach (db, nm->db)
649 nat64_db_st_walk (db, p, nat64_cli_st_walk, &ctx);
654 unformat_free (line_input);
659 static clib_error_t *
660 nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
661 vlib_cli_command_t * cmd)
663 vnet_main_t *vnm = vnet_get_main ();
664 clib_error_t *error = 0;
665 unformat_input_t _line_input, *line_input = &_line_input;
667 u32 vrf_id = 0, sw_if_index = ~0;
668 ip6_address_t prefix;
672 if (!unformat_user (input, unformat_line_input, line_input))
675 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
678 (line_input, "%U/%u", unformat_ip6_address, &prefix, &plen))
680 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
682 else if (unformat (line_input, "del"))
686 (line_input, "interface %U", unformat_vnet_sw_interface, vnm,
691 error = clib_error_return (0, "unknown input: '%U'",
692 format_unformat_error, line_input);
699 error = clib_error_return (0, "NAT64 prefix must be set.");
703 rv = nat64_add_del_prefix (&prefix, (u8) plen, vrf_id, is_add);
707 case VNET_API_ERROR_NO_SUCH_ENTRY:
708 error = clib_error_return (0, "NAT64 prefix not exist.");
710 case VNET_API_ERROR_INVALID_VALUE:
711 error = clib_error_return (0, "Invalid prefix length.");
718 * Add RX interface route, whenNAT isn't running on the real input
721 if (sw_if_index != ~0)
724 fib_prefix_t fibpfx = {
726 .fp_proto = FIB_PROTOCOL_IP6,
734 fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6,
735 vrf_id, FIB_SOURCE_PLUGIN_HI);
736 fib_table_entry_update_one_path (fib_index, &fibpfx,
737 FIB_SOURCE_PLUGIN_HI,
741 NULL, FIB_ROUTE_PATH_INTF_RX);
745 fib_index = fib_table_find (FIB_PROTOCOL_IP6, vrf_id);
746 fib_table_entry_path_remove (fib_index, &fibpfx,
747 FIB_SOURCE_PLUGIN_HI,
750 FIB_ROUTE_PATH_INTF_RX);
751 fib_table_unlock (fib_index, FIB_PROTOCOL_IP6,
752 FIB_SOURCE_PLUGIN_HI);
757 unformat_free (line_input);
763 nat64_cli_prefix_walk (nat64_prefix_t * p, void *ctx)
765 vlib_main_t *vm = ctx;
767 vlib_cli_output (vm, " %U/%u tenant-vrf %u",
768 format_ip6_address, &p->prefix, p->plen, p->vrf_id);
773 static clib_error_t *
774 nat64_show_prefix_command_fn (vlib_main_t * vm,
775 unformat_input_t * input,
776 vlib_cli_command_t * cmd)
778 vlib_cli_output (vm, "NAT64 prefix:");
779 nat64_prefix_walk (nat64_cli_prefix_walk, vm);
784 static clib_error_t *
785 nat64_add_interface_address_command_fn (vlib_main_t * vm,
786 unformat_input_t * input,
787 vlib_cli_command_t * cmd)
789 vnet_main_t *vnm = vnet_get_main ();
790 unformat_input_t _line_input, *line_input = &_line_input;
794 clib_error_t *error = 0;
796 /* Get a line of input. */
797 if (!unformat_user (input, unformat_line_input, line_input))
800 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
803 (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
804 else if (unformat (line_input, "del"))
808 error = clib_error_return (0, "unknown input '%U'",
809 format_unformat_error, line_input);
814 rv = nat64_add_interface_address (sw_if_index, is_add);
818 case VNET_API_ERROR_NO_SUCH_ENTRY:
819 error = clib_error_return (0, "entry not exist");
821 case VNET_API_ERROR_VALUE_EXIST:
822 error = clib_error_return (0, "entry exist");
829 unformat_free (line_input);
838 * @cliexstart{nat64 add pool address}
839 * Add/delete NAT64 pool address.
840 * To add single NAT64 pool address use:
841 * vpp# nat64 add pool address 10.1.1.10
842 * To add NAT64 pool address range use:
843 * vpp# nat64 add pool address 10.1.1.2 - 10.1.1.5
844 * To add NAT64 pool address for specific tenant use:
845 * vpp# nat64 add pool address 10.1.1.100 tenant-vrf 100
848 VLIB_CLI_COMMAND (nat64_add_pool_address_command, static) = {
849 .path = "nat64 add pool address",
850 .short_help = "nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
851 "[tenant-vrf <vrf-id>] [del]",
852 .function = nat64_add_del_pool_addr_command_fn,
857 * @cliexstart{show nat64 pool}
859 * vpp# show nat64 pool
861 * 10.1.1.3 tenant VRF: 0
862 * 10.1.1.10 tenant VRF: 10
865 VLIB_CLI_COMMAND (show_nat64_pool_command, static) = {
866 .path = "show nat64 pool",
867 .short_help = "show nat64 pool",
868 .function = nat64_show_pool_command_fn,
873 * @cliexstart{set interface nat64}
874 * Enable/disable NAT64 feature on the interface.
875 * To enable NAT64 feature with local (IPv6) network interface
876 * GigabitEthernet0/8/0 and external (IPv4) network interface
877 * GigabitEthernet0/a/0 use:
878 * vpp# set interface nat64 in GigabitEthernet0/8/0 out GigabitEthernet0/a/0
881 VLIB_CLI_COMMAND (set_interface_nat64_command, static) = {
882 .path = "set interface nat64",
883 .short_help = "set interface nat64 in|out <intfc> [del]",
884 .function = nat64_interface_feature_command_fn,
889 * @cliexstart{show nat64 interfaces}
890 * Show interfaces with NAT64 feature.
891 * To show interfaces with NAT64 feature use:
892 * vpp# show nat64 interfaces
894 * GigabitEthernet0/8/0 in
895 * GigabitEthernet0/a/0 out
898 VLIB_CLI_COMMAND (show_nat64_interfaces_command, static) = {
899 .path = "show nat64 interfaces",
900 .short_help = "show nat64 interfaces",
901 .function = nat64_show_interfaces_command_fn,
906 * @cliexstart{nat64 add static bib}
907 * Add/delete NAT64 static BIB entry.
908 * To create NAT64 satatic BIB entry use:
909 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp
910 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10
913 VLIB_CLI_COMMAND (nat64_add_del_static_bib_command, static) = {
914 .path = "nat64 add static bib",
915 .short_help = "nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
916 "tcp|udp|icmp [vfr <table-id>] [del]",
917 .function = nat64_add_del_static_bib_command_fn,
922 * @cliexstart{show nat64 bib}
923 * Show NAT64 BIB entries.
924 * To show NAT64 TCP BIB entries use:
925 * vpp# show nat64 bib tcp
927 * fd01:1::2 6303 10.0.0.3 62303 tcp vrf 0 dynamic 1 sessions
928 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp vrf 0 static 2 sessions
929 * To show NAT64 UDP BIB entries use:
930 * vpp# show nat64 bib udp
932 * fd01:1::2 6304 10.0.0.3 10546 udp vrf 0 dynamic 10 sessions
933 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10 static 0 sessions
934 * To show NAT64 ICMP BIB entries use:
935 * vpp# show nat64 bib icmp
937 * fd01:1::2 6305 10.0.0.3 63209 icmp vrf 10 dynamic 1 sessions
940 VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
941 .path = "show nat64 bib",
942 .short_help = "show nat64 bib all|tcp|udp|icmp|unknown",
943 .function = nat64_show_bib_command_fn,
948 * @cliexstart{set nat64 timeouts}
949 * Set NAT64 session timeouts (in seconds).
950 * To set NAT64 session timeoutes use use:
951 * vpp# set nat64 timeouts udp 200 icmp 30 tcp-trans 250 tcp-est 7450
952 * To reset NAT64 session timeoutes to default values use:
953 * vpp# set nat64 timeouts reset
956 VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = {
957 .path = "set nat64 timeouts",
958 .short_help = "set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> "
959 "tcp-est <sec> tcp-incoming-syn <sec> | reset",
960 .function = nat64_set_timeouts_command_fn,
965 * @cliexstart{show nat64 timeoutss}
966 * Show NAT64 session timeouts:
967 * vpp# show nat64 timeouts
968 * NAT64 session timeouts:
971 * TCP transitory 240sec
972 * TCP established 7440sec
973 * TCP incoming SYN 6sec
976 VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = {
977 .path = "show nat64 timeouts",
978 .short_help = "show nat64 timeouts",
979 .function = nat64_show_timeouts_command_fn,
984 * @cliexstart{show nat64 session table}
985 * Show NAT64 session table.
986 * To show NAT64 TCP session table use:
987 * vpp# show nat64 session table tcp
988 * NAT64 tcp session table:
989 * fd01:1::2 6303 64:ff9b::ac10:202 20 10.0.0.3 62303 172.16.2.2 20 tcp vrf 0
990 * fd01:3::2 6303 64:ff9b::ac10:202 20 10.0.10.3 21300 172.16.2.2 20 tcp vrf 10
991 * To show NAT64 UDP session table use:
992 * #vpp show nat64 session table udp
993 * NAT64 udp session table:
994 * fd01:1::2 6304 64:ff9b::ac10:202 20 10.0.0.3 10546 172.16.2.2 20 udp vrf 0
995 * fd01:3::2 6304 64:ff9b::ac10:202 20 10.0.10.3 58627 172.16.2.2 20 udp vrf 10
996 * fd01:1::2 1235 64:ff9b::a00:3 4023 10.0.0.3 24488 10.0.0.3 4023 udp vrf 0
997 * fd01:1::3 23 64:ff9b::a00:3 24488 10.0.0.3 4023 10.0.0.3 24488 udp vrf 0
998 * To show NAT64 ICMP session table use:
999 * #vpp show nat64 session table icmp
1000 * NAT64 icmp session table:
1001 * fd01:1::2 64:ff9b::ac10:202 6305 10.0.0.3 172.16.2.2 63209 icmp vrf 0
1004 VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
1005 .path = "show nat64 session table",
1006 .short_help = "show nat64 session table all|tcp|udp|icmp|unknown",
1007 .function = nat64_show_st_command_fn,
1012 * @cliexstart{nat64 add prefix}
1013 * Set NAT64 prefix for generating IPv6 representations of IPv4 addresses.
1014 * To set NAT64 global prefix use:
1015 * vpp# nat64 add prefix 2001:db8::/32
1016 * To set NAT64 prefix for specific tenant use:
1017 * vpp# nat64 add prefix 2001:db8:122:300::/56 tenant-vrf 10
1020 VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
1021 .path = "nat64 add prefix",
1022 .short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
1023 "[del] [interface <interface]",
1024 .function = nat64_add_del_prefix_command_fn,
1029 * @cliexstart{show nat64 prefix}
1030 * Show NAT64 prefix.
1031 * To show NAT64 prefix use:
1032 * vpp# show nat64 prefix
1034 * 2001:db8::/32 tenant-vrf 0
1035 * 2001:db8:122:300::/56 tenant-vrf 10
1038 VLIB_CLI_COMMAND (show_nat64_prefix_command, static) = {
1039 .path = "show nat64 prefix",
1040 .short_help = "show nat64 prefix",
1041 .function = nat64_show_prefix_command_fn,
1046 * @cliexstart{nat64 add interface address}
1047 * Add/delete NAT64 pool address from specific (DHCP addressed) interface.
1048 * To add NAT64 pool address from specific interface use:
1049 * vpp# nat64 add interface address GigabitEthernet0/8/0
1052 VLIB_CLI_COMMAND (nat64_add_interface_address_command, static) = {
1053 .path = "nat64 add interface address",
1054 .short_help = "nat64 add interface address <interface> [del]",
1055 .function = nat64_add_interface_address_command_fn,
1060 * fd.io coding-style-patch-verification: ON
1063 * eval: (c-set-style "gnu")