2 * Copyright (c) 2018 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.
21 #include <nat/nat_ipfix_logging.h>
22 #include <nat/nat_det.h>
23 #include <vnet/fib/fib_table.h>
26 set_workers_command_fn (vlib_main_t * vm,
27 unformat_input_t * input, vlib_cli_command_t * cmd)
29 unformat_input_t _line_input, *line_input = &_line_input;
32 clib_error_t *error = 0;
34 /* Get a line of input. */
35 if (!unformat_user (input, unformat_line_input, line_input))
38 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
40 if (unformat (line_input, "%U", unformat_bitmap_list, &bitmap))
44 error = clib_error_return (0, "unknown input '%U'",
45 format_unformat_error, line_input);
52 error = clib_error_return (0, "List of workers must be specified.");
56 rv = snat_set_workers (bitmap);
58 clib_bitmap_free (bitmap);
62 case VNET_API_ERROR_INVALID_WORKER:
63 error = clib_error_return (0, "Invalid worker(s).");
65 case VNET_API_ERROR_FEATURE_DISABLED:
66 error = clib_error_return (0,
67 "Supported only if 2 or more workes available.");
74 unformat_free (line_input);
80 nat_show_workers_commnad_fn (vlib_main_t * vm, unformat_input_t * input,
81 vlib_cli_command_t * cmd)
83 snat_main_t *sm = &snat_main;
86 if (sm->num_workers > 1)
88 vlib_cli_output (vm, "%d workers", vec_len (sm->workers));
90 vec_foreach (worker, sm->workers)
92 vlib_worker_thread_t *w =
93 vlib_worker_threads + *worker + sm->first_worker_index;
94 vlib_cli_output (vm, " %s", w->name);
102 static clib_error_t *
103 snat_ipfix_logging_enable_disable_command_fn (vlib_main_t * vm,
104 unformat_input_t * input,
105 vlib_cli_command_t * cmd)
107 unformat_input_t _line_input, *line_input = &_line_input;
112 clib_error_t *error = 0;
114 /* Get a line of input. */
115 if (!unformat_user (input, unformat_line_input, line_input))
118 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
120 if (unformat (line_input, "domain %d", &domain_id))
122 else if (unformat (line_input, "src-port %d", &src_port))
124 else if (unformat (line_input, "disable"))
128 error = clib_error_return (0, "unknown input '%U'",
129 format_unformat_error, line_input);
134 rv = snat_ipfix_logging_enable_disable (enable, domain_id, (u16) src_port);
138 error = clib_error_return (0, "ipfix logging enable failed");
143 unformat_free (line_input);
148 static clib_error_t *
149 nat44_set_alloc_addr_and_port_alg_command_fn (vlib_main_t * vm,
150 unformat_input_t * input,
151 vlib_cli_command_t * cmd)
153 unformat_input_t _line_input, *line_input = &_line_input;
154 clib_error_t *error = 0;
155 u32 psid, psid_offset, psid_length;
157 /* Get a line of input. */
158 if (!unformat_user (input, unformat_line_input, line_input))
161 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
163 if (unformat (line_input, "default"))
164 nat_set_alloc_addr_and_port_default ();
167 (line_input, "map-e psid %d psid-offset %d psid-len %d", &psid,
168 &psid_offset, &psid_length))
169 nat_set_alloc_addr_and_port_mape ((u16) psid, (u16) psid_offset,
173 error = clib_error_return (0, "unknown input '%U'",
174 format_unformat_error, line_input);
180 unformat_free (line_input);
185 static clib_error_t *
186 add_address_command_fn (vlib_main_t * vm,
187 unformat_input_t * input, vlib_cli_command_t * cmd)
189 unformat_input_t _line_input, *line_input = &_line_input;
190 snat_main_t *sm = &snat_main;
191 ip4_address_t start_addr, end_addr, this_addr;
192 u32 start_host_order, end_host_order;
197 clib_error_t *error = 0;
200 /* Get a line of input. */
201 if (!unformat_user (input, unformat_line_input, line_input))
204 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
206 if (unformat (line_input, "%U - %U",
207 unformat_ip4_address, &start_addr,
208 unformat_ip4_address, &end_addr))
210 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
212 else if (unformat (line_input, "%U", unformat_ip4_address, &start_addr))
213 end_addr = start_addr;
214 else if (unformat (line_input, "twice-nat"))
216 else if (unformat (line_input, "del"))
220 error = clib_error_return (0, "unknown input '%U'",
221 format_unformat_error, line_input);
226 if (sm->static_mapping_only)
228 error = clib_error_return (0, "static mapping only mode");
232 start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
233 end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
235 if (end_host_order < start_host_order)
237 error = clib_error_return (0, "end address less than start address");
241 count = (end_host_order - start_host_order) + 1;
244 clib_warning ("%U - %U, %d addresses...",
245 format_ip4_address, &start_addr,
246 format_ip4_address, &end_addr, count);
248 this_addr = start_addr;
250 for (i = 0; i < count; i++)
253 snat_add_address (sm, &this_addr, vrf_id, twice_nat);
255 rv = snat_del_address (sm, this_addr, 0, twice_nat);
259 case VNET_API_ERROR_NO_SUCH_ENTRY:
260 error = clib_error_return (0, "S-NAT address not exist.");
262 case VNET_API_ERROR_UNSPECIFIED:
264 clib_error_return (0, "S-NAT address used in static mapping.");
271 nat44_add_del_address_dpo (this_addr, is_add);
273 increment_v4_address (&this_addr);
277 unformat_free (line_input);
282 static clib_error_t *
283 nat44_show_addresses_command_fn (vlib_main_t * vm, unformat_input_t * input,
284 vlib_cli_command_t * cmd)
286 snat_main_t *sm = &snat_main;
289 vlib_cli_output (vm, "NAT44 pool addresses:");
291 vec_foreach (ap, sm->addresses)
293 vlib_cli_output (vm, "%U", format_ip4_address, &ap->addr);
294 if (ap->fib_index != ~0)
295 vlib_cli_output (vm, " tenant VRF: %u",
296 fib_table_get(ap->fib_index, FIB_PROTOCOL_IP4)->ft_table_id);
298 vlib_cli_output (vm, " tenant VRF independent");
299 #define _(N, i, n, s) \
300 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
301 foreach_snat_protocol
304 vlib_cli_output (vm, "NAT44 twice-nat pool addresses:");
305 vec_foreach (ap, sm->twice_nat_addresses)
307 vlib_cli_output (vm, "%U", format_ip4_address, &ap->addr);
308 if (ap->fib_index != ~0)
309 vlib_cli_output (vm, " tenant VRF: %u",
310 fib_table_get(ap->fib_index, FIB_PROTOCOL_IP4)->ft_table_id);
312 vlib_cli_output (vm, " tenant VRF independent");
313 #define _(N, i, n, s) \
314 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
315 foreach_snat_protocol
322 static clib_error_t *
323 snat_feature_command_fn (vlib_main_t * vm,
324 unformat_input_t * input, vlib_cli_command_t * cmd)
326 unformat_input_t _line_input, *line_input = &_line_input;
327 vnet_main_t *vnm = vnet_get_main ();
328 clib_error_t *error = 0;
330 u32 *inside_sw_if_indices = 0;
331 u32 *outside_sw_if_indices = 0;
332 u8 is_output_feature = 0;
338 /* Get a line of input. */
339 if (!unformat_user (input, unformat_line_input, line_input))
342 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
344 if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
346 vec_add1 (inside_sw_if_indices, sw_if_index);
347 else if (unformat (line_input, "out %U", unformat_vnet_sw_interface,
349 vec_add1 (outside_sw_if_indices, sw_if_index);
350 else if (unformat (line_input, "output-feature"))
351 is_output_feature = 1;
352 else if (unformat (line_input, "del"))
356 error = clib_error_return (0, "unknown input '%U'",
357 format_unformat_error, line_input);
362 if (vec_len (inside_sw_if_indices))
364 for (i = 0; i < vec_len (inside_sw_if_indices); i++)
366 sw_if_index = inside_sw_if_indices[i];
367 if (is_output_feature)
369 if (snat_interface_add_del_output_feature
370 (sw_if_index, 1, is_del))
372 error = clib_error_return (0, "%s %U failed",
373 is_del ? "del" : "add",
374 format_vnet_sw_interface_name,
375 vnm, vnet_get_sw_interface (vnm,
382 if (snat_interface_add_del (sw_if_index, 1, is_del))
384 error = clib_error_return (0, "%s %U failed",
385 is_del ? "del" : "add",
386 format_vnet_sw_interface_name,
387 vnm, vnet_get_sw_interface (vnm,
395 if (vec_len (outside_sw_if_indices))
397 for (i = 0; i < vec_len (outside_sw_if_indices); i++)
399 sw_if_index = outside_sw_if_indices[i];
400 if (is_output_feature)
402 if (snat_interface_add_del_output_feature
403 (sw_if_index, 0, is_del))
405 error = clib_error_return (0, "%s %U failed",
406 is_del ? "del" : "add",
407 format_vnet_sw_interface_name,
408 vnm, vnet_get_sw_interface (vnm,
415 if (snat_interface_add_del (sw_if_index, 0, is_del))
417 error = clib_error_return (0, "%s %U failed",
418 is_del ? "del" : "add",
419 format_vnet_sw_interface_name,
420 vnm, vnet_get_sw_interface (vnm,
429 unformat_free (line_input);
430 vec_free (inside_sw_if_indices);
431 vec_free (outside_sw_if_indices);
436 static clib_error_t *
437 nat44_show_interfaces_command_fn (vlib_main_t * vm, unformat_input_t * input,
438 vlib_cli_command_t * cmd)
440 snat_main_t *sm = &snat_main;
442 vnet_main_t *vnm = vnet_get_main ();
444 vlib_cli_output (vm, "NAT44 interfaces:");
446 pool_foreach (i, sm->interfaces,
448 vlib_cli_output (vm, " %U %s", format_vnet_sw_interface_name, vnm,
449 vnet_get_sw_interface (vnm, i->sw_if_index),
450 (nat_interface_is_inside(i) &&
451 nat_interface_is_outside(i)) ? "in out" :
452 (nat_interface_is_inside(i) ? "in" : "out"));
455 pool_foreach (i, sm->output_feature_interfaces,
457 vlib_cli_output (vm, " %U output-feature %s",
458 format_vnet_sw_interface_name, vnm,
459 vnet_get_sw_interface (vnm, i->sw_if_index),
460 (nat_interface_is_inside(i) &&
461 nat_interface_is_outside(i)) ? "in out" :
462 (nat_interface_is_inside(i) ? "in" : "out"));
469 static clib_error_t *
470 add_static_mapping_command_fn (vlib_main_t * vm,
471 unformat_input_t * input,
472 vlib_cli_command_t * cmd)
474 unformat_input_t _line_input, *line_input = &_line_input;
475 clib_error_t *error = 0;
476 ip4_address_t l_addr, e_addr;
477 u32 l_port = 0, e_port = 0, vrf_id = ~0;
480 u32 sw_if_index = ~0;
481 vnet_main_t *vnm = vnet_get_main ();
483 snat_protocol_t proto = ~0;
488 /* Get a line of input. */
489 if (!unformat_user (input, unformat_line_input, line_input))
492 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
494 if (unformat (line_input, "local %U %u", unformat_ip4_address, &l_addr,
498 if (unformat (line_input, "local %U", unformat_ip4_address, &l_addr))
500 else if (unformat (line_input, "external %U %u", unformat_ip4_address,
503 else if (unformat (line_input, "external %U", unformat_ip4_address,
506 else if (unformat (line_input, "external %U %u",
507 unformat_vnet_sw_interface, vnm, &sw_if_index,
511 else if (unformat (line_input, "external %U",
512 unformat_vnet_sw_interface, vnm, &sw_if_index))
514 else if (unformat (line_input, "vrf %u", &vrf_id))
516 else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
518 else if (unformat (line_input, "twice-nat"))
520 else if (unformat (line_input, "out2in-only"))
522 else if (unformat (line_input, "del"))
526 error = clib_error_return (0, "unknown input: '%U'",
527 format_unformat_error, line_input);
532 if (twice_nat && addr_only)
534 error = clib_error_return (0, "twice NAT only for 1:1 NAPT");
538 if (!addr_only && !proto_set)
540 error = clib_error_return (0, "missing protocol");
544 rv = snat_add_static_mapping (l_addr, e_addr, (u16) l_port, (u16) e_port,
545 vrf_id, addr_only, sw_if_index, proto, is_add,
546 twice_nat, out2in_only, 0);
550 case VNET_API_ERROR_INVALID_VALUE:
551 error = clib_error_return (0, "External port already in use.");
553 case VNET_API_ERROR_NO_SUCH_ENTRY:
555 error = clib_error_return (0, "External addres must be allocated.");
557 error = clib_error_return (0, "Mapping not exist.");
559 case VNET_API_ERROR_NO_SUCH_FIB:
560 error = clib_error_return (0, "No such VRF id.");
562 case VNET_API_ERROR_VALUE_EXIST:
563 error = clib_error_return (0, "Mapping already exist.");
570 unformat_free (line_input);
575 static clib_error_t *
576 add_identity_mapping_command_fn (vlib_main_t * vm,
577 unformat_input_t * input,
578 vlib_cli_command_t * cmd)
580 unformat_input_t _line_input, *line_input = &_line_input;
581 clib_error_t *error = 0;
583 u32 port = 0, vrf_id = ~0;
586 u32 sw_if_index = ~0;
587 vnet_main_t *vnm = vnet_get_main ();
589 snat_protocol_t proto;
593 /* Get a line of input. */
594 if (!unformat_user (input, unformat_line_input, line_input))
597 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
599 if (unformat (line_input, "%U", unformat_ip4_address, &addr))
601 else if (unformat (line_input, "external %U",
602 unformat_vnet_sw_interface, vnm, &sw_if_index))
604 else if (unformat (line_input, "vrf %u", &vrf_id))
606 else if (unformat (line_input, "%U %u", unformat_snat_protocol, &proto,
609 else if (unformat (line_input, "del"))
613 error = clib_error_return (0, "unknown input: '%U'",
614 format_unformat_error, line_input);
619 rv = snat_add_static_mapping (addr, addr, (u16) port, (u16) port,
620 vrf_id, addr_only, sw_if_index, proto, is_add,
625 case VNET_API_ERROR_INVALID_VALUE:
626 error = clib_error_return (0, "External port already in use.");
628 case VNET_API_ERROR_NO_SUCH_ENTRY:
630 error = clib_error_return (0, "External addres must be allocated.");
632 error = clib_error_return (0, "Mapping not exist.");
634 case VNET_API_ERROR_NO_SUCH_FIB:
635 error = clib_error_return (0, "No such VRF id.");
637 case VNET_API_ERROR_VALUE_EXIST:
638 error = clib_error_return (0, "Mapping already exist.");
645 unformat_free (line_input);
650 static clib_error_t *
651 add_lb_static_mapping_command_fn (vlib_main_t * vm,
652 unformat_input_t * input,
653 vlib_cli_command_t * cmd)
655 unformat_input_t _line_input, *line_input = &_line_input;
656 clib_error_t *error = 0;
657 ip4_address_t l_addr, e_addr;
658 u32 l_port = 0, e_port = 0, vrf_id = 0, probability = 0;
661 snat_protocol_t proto;
663 nat44_lb_addr_port_t *locals = 0, local;
667 /* Get a line of input. */
668 if (!unformat_user (input, unformat_line_input, line_input))
671 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
673 if (unformat (line_input, "local %U:%u probability %u",
674 unformat_ip4_address, &l_addr, &l_port, &probability))
676 memset (&local, 0, sizeof (local));
678 local.port = (u16) l_port;
679 local.probability = (u8) probability;
680 vec_add1 (locals, local);
682 else if (unformat (line_input, "external %U:%u", unformat_ip4_address,
685 else if (unformat (line_input, "vrf %u", &vrf_id))
687 else if (unformat (line_input, "protocol %U", unformat_snat_protocol,
690 else if (unformat (line_input, "twice-nat"))
692 else if (unformat (line_input, "out2in-only"))
694 else if (unformat (line_input, "del"))
698 error = clib_error_return (0, "unknown input: '%U'",
699 format_unformat_error, line_input);
704 if (vec_len (locals) < 2)
706 error = clib_error_return (0, "at least two local must be set");
712 error = clib_error_return (0, "missing protocol");
716 rv = nat44_add_del_lb_static_mapping (e_addr, (u16) e_port, proto, vrf_id,
717 locals, is_add, twice_nat,
722 case VNET_API_ERROR_INVALID_VALUE:
723 error = clib_error_return (0, "External port already in use.");
725 case VNET_API_ERROR_NO_SUCH_ENTRY:
727 error = clib_error_return (0, "External addres must be allocated.");
729 error = clib_error_return (0, "Mapping not exist.");
731 case VNET_API_ERROR_VALUE_EXIST:
732 error = clib_error_return (0, "Mapping already exist.");
739 unformat_free (line_input);
745 static clib_error_t *
746 nat44_show_static_mappings_command_fn (vlib_main_t * vm,
747 unformat_input_t * input,
748 vlib_cli_command_t * cmd)
750 snat_main_t *sm = &snat_main;
751 snat_static_mapping_t *m;
752 snat_static_map_resolve_t *rp;
754 vlib_cli_output (vm, "NAT44 static mappings:");
756 pool_foreach (m, sm->static_mappings,
758 vlib_cli_output (vm, " %U", format_snat_static_mapping, m);
760 vec_foreach (rp, sm->to_resolve)
761 vlib_cli_output (vm, " %U", format_snat_static_map_to_resolve, rp);
767 static clib_error_t *
768 snat_add_interface_address_command_fn (vlib_main_t * vm,
769 unformat_input_t * input,
770 vlib_cli_command_t * cmd)
772 snat_main_t *sm = &snat_main;
773 unformat_input_t _line_input, *line_input = &_line_input;
777 clib_error_t *error = 0;
780 /* Get a line of input. */
781 if (!unformat_user (input, unformat_line_input, line_input))
784 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
786 if (unformat (line_input, "%U", unformat_vnet_sw_interface,
787 sm->vnet_main, &sw_if_index))
789 else if (unformat (line_input, "twice-nat"))
791 else if (unformat (line_input, "del"))
795 error = clib_error_return (0, "unknown input '%U'",
796 format_unformat_error, line_input);
801 rv = snat_add_interface_address (sm, sw_if_index, is_del, twice_nat);
809 error = clib_error_return (0, "snat_add_interface_address returned %d",
815 unformat_free (line_input);
820 static clib_error_t *
821 nat44_show_interface_address_command_fn (vlib_main_t * vm,
822 unformat_input_t * input,
823 vlib_cli_command_t * cmd)
825 snat_main_t *sm = &snat_main;
826 vnet_main_t *vnm = vnet_get_main ();
830 vlib_cli_output (vm, "NAT44 pool address interfaces:");
831 vec_foreach (sw_if_index, sm->auto_add_sw_if_indices)
833 vlib_cli_output (vm, " %U", format_vnet_sw_interface_name, vnm,
834 vnet_get_sw_interface (vnm, *sw_if_index));
836 vlib_cli_output (vm, "NAT44 twice-nat pool address interfaces:");
837 vec_foreach (sw_if_index, sm->auto_add_sw_if_indices_twice_nat)
839 vlib_cli_output (vm, " %U", format_vnet_sw_interface_name, vnm,
840 vnet_get_sw_interface (vnm, *sw_if_index));
847 static clib_error_t *
848 nat44_show_sessions_command_fn (vlib_main_t * vm, unformat_input_t * input,
849 vlib_cli_command_t * cmd)
852 snat_main_t *sm = &snat_main;
853 snat_main_per_thread_data_t *tsm;
857 if (unformat (input, "detail"))
860 vlib_cli_output (vm, "NAT44 sessions:");
863 vec_foreach_index (i, sm->per_thread_data)
865 tsm = vec_elt_at_index (sm->per_thread_data, i);
867 pool_foreach (u, tsm->users,
869 vlib_cli_output (vm, " %U", format_snat_user, tsm, u, verbose);
877 static clib_error_t *
878 nat44_del_session_command_fn (vlib_main_t * vm,
879 unformat_input_t * input,
880 vlib_cli_command_t * cmd)
882 snat_main_t *sm = &snat_main;
883 unformat_input_t _line_input, *line_input = &_line_input;
885 clib_error_t *error = 0;
887 u32 port = 0, vrf_id = sm->outside_vrf_id;
888 snat_protocol_t proto;
891 /* Get a line of input. */
892 if (!unformat_user (input, unformat_line_input, line_input))
895 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
898 (line_input, "%U:%u %U", unformat_ip4_address, &addr, &port,
899 unformat_snat_protocol, &proto))
901 else if (unformat (line_input, "in"))
904 vrf_id = sm->inside_vrf_id;
906 else if (unformat (line_input, "vrf %u", &vrf_id))
910 error = clib_error_return (0, "unknown input '%U'",
911 format_unformat_error, line_input);
916 rv = nat44_del_session (sm, &addr, port, proto, vrf_id, is_in);
924 error = clib_error_return (0, "nat44_del_session returned %d", rv);
929 unformat_free (line_input);
934 static clib_error_t *
935 snat_forwarding_set_command_fn (vlib_main_t * vm,
936 unformat_input_t * input,
937 vlib_cli_command_t * cmd)
939 snat_main_t *sm = &snat_main;
940 unformat_input_t _line_input, *line_input = &_line_input;
941 u8 forwarding_enable;
942 u8 forwarding_enable_set = 0;
943 clib_error_t *error = 0;
945 /* Get a line of input. */
946 if (!unformat_user (input, unformat_line_input, line_input))
947 return clib_error_return (0, "'enable' or 'disable' expected");
949 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
951 if (!forwarding_enable_set && unformat (line_input, "enable"))
953 forwarding_enable = 1;
954 forwarding_enable_set = 1;
956 else if (!forwarding_enable_set && unformat (line_input, "disable"))
958 forwarding_enable = 0;
959 forwarding_enable_set = 1;
963 error = clib_error_return (0, "unknown input '%U'",
964 format_unformat_error, line_input);
969 if (!forwarding_enable_set)
971 error = clib_error_return (0, "'enable' or 'disable' expected");
975 sm->forwarding_enabled = forwarding_enable;
978 unformat_free (line_input);
983 static clib_error_t *
984 snat_det_map_command_fn (vlib_main_t * vm,
985 unformat_input_t * input, vlib_cli_command_t * cmd)
987 snat_main_t *sm = &snat_main;
988 unformat_input_t _line_input, *line_input = &_line_input;
989 ip4_address_t in_addr, out_addr;
990 u32 in_plen, out_plen;
992 clib_error_t *error = 0;
994 /* Get a line of input. */
995 if (!unformat_user (input, unformat_line_input, line_input))
998 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1001 (line_input, "in %U/%u", unformat_ip4_address, &in_addr, &in_plen))
1005 (line_input, "out %U/%u", unformat_ip4_address, &out_addr,
1008 else if (unformat (line_input, "del"))
1012 error = clib_error_return (0, "unknown input '%U'",
1013 format_unformat_error, line_input);
1018 rv = snat_det_add_map (sm, &in_addr, (u8) in_plen, &out_addr, (u8) out_plen,
1023 error = clib_error_return (0, "snat_det_add_map return %d", rv);
1028 unformat_free (line_input);
1033 static clib_error_t *
1034 nat44_det_show_mappings_command_fn (vlib_main_t * vm,
1035 unformat_input_t * input,
1036 vlib_cli_command_t * cmd)
1038 snat_main_t *sm = &snat_main;
1041 vlib_cli_output (vm, "NAT44 deterministic mappings:");
1043 pool_foreach (dm, sm->det_maps,
1045 vlib_cli_output (vm, " in %U/%d out %U/%d\n",
1046 format_ip4_address, &dm->in_addr, dm->in_plen,
1047 format_ip4_address, &dm->out_addr, dm->out_plen);
1048 vlib_cli_output (vm, " outside address sharing ratio: %d\n",
1050 vlib_cli_output (vm, " number of ports per inside host: %d\n",
1051 dm->ports_per_host);
1052 vlib_cli_output (vm, " sessions number: %d\n", dm->ses_num);
1059 static clib_error_t *
1060 snat_det_forward_command_fn (vlib_main_t * vm,
1061 unformat_input_t * input,
1062 vlib_cli_command_t * cmd)
1064 snat_main_t *sm = &snat_main;
1065 unformat_input_t _line_input, *line_input = &_line_input;
1066 ip4_address_t in_addr, out_addr;
1069 clib_error_t *error = 0;
1071 /* Get a line of input. */
1072 if (!unformat_user (input, unformat_line_input, line_input))
1075 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1077 if (unformat (line_input, "%U", unformat_ip4_address, &in_addr))
1081 error = clib_error_return (0, "unknown input '%U'",
1082 format_unformat_error, line_input);
1087 dm = snat_det_map_by_user (sm, &in_addr);
1089 vlib_cli_output (vm, "no match");
1092 snat_det_forward (dm, &in_addr, &out_addr, &lo_port);
1093 vlib_cli_output (vm, "%U:<%d-%d>", format_ip4_address, &out_addr,
1094 lo_port, lo_port + dm->ports_per_host - 1);
1098 unformat_free (line_input);
1103 static clib_error_t *
1104 snat_det_reverse_command_fn (vlib_main_t * vm,
1105 unformat_input_t * input,
1106 vlib_cli_command_t * cmd)
1108 snat_main_t *sm = &snat_main;
1109 unformat_input_t _line_input, *line_input = &_line_input;
1110 ip4_address_t in_addr, out_addr;
1113 clib_error_t *error = 0;
1115 /* Get a line of input. */
1116 if (!unformat_user (input, unformat_line_input, line_input))
1119 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1122 (line_input, "%U:%d", unformat_ip4_address, &out_addr, &out_port))
1126 error = clib_error_return (0, "unknown input '%U'",
1127 format_unformat_error, line_input);
1132 if (out_port < 1024 || out_port > 65535)
1134 error = clib_error_return (0, "wrong port, must be <1024-65535>");
1138 dm = snat_det_map_by_out (sm, &out_addr);
1140 vlib_cli_output (vm, "no match");
1143 snat_det_reverse (dm, &out_addr, (u16) out_port, &in_addr);
1144 vlib_cli_output (vm, "%U", format_ip4_address, &in_addr);
1148 unformat_free (line_input);
1153 static clib_error_t *
1154 set_timeout_command_fn (vlib_main_t * vm,
1155 unformat_input_t * input, vlib_cli_command_t * cmd)
1157 snat_main_t *sm = &snat_main;
1158 unformat_input_t _line_input, *line_input = &_line_input;
1159 clib_error_t *error = 0;
1161 /* Get a line of input. */
1162 if (!unformat_user (input, unformat_line_input, line_input))
1165 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1167 if (unformat (line_input, "udp %u", &sm->udp_timeout))
1169 else if (unformat (line_input, "tcp-established %u",
1170 &sm->tcp_established_timeout))
1172 else if (unformat (line_input, "tcp-transitory %u",
1173 &sm->tcp_transitory_timeout))
1175 else if (unformat (line_input, "icmp %u", &sm->icmp_timeout))
1177 else if (unformat (line_input, "reset"))
1179 sm->udp_timeout = SNAT_UDP_TIMEOUT;
1180 sm->tcp_established_timeout = SNAT_TCP_ESTABLISHED_TIMEOUT;
1181 sm->tcp_transitory_timeout = SNAT_TCP_TRANSITORY_TIMEOUT;
1182 sm->icmp_timeout = SNAT_ICMP_TIMEOUT;
1186 error = clib_error_return (0, "unknown input '%U'",
1187 format_unformat_error, line_input);
1193 unformat_free (line_input);
1198 static clib_error_t *
1199 nat44_det_show_timeouts_command_fn (vlib_main_t * vm,
1200 unformat_input_t * input,
1201 vlib_cli_command_t * cmd)
1203 snat_main_t *sm = &snat_main;
1205 vlib_cli_output (vm, "udp timeout: %dsec", sm->udp_timeout);
1206 vlib_cli_output (vm, "tcp-established timeout: %dsec",
1207 sm->tcp_established_timeout);
1208 vlib_cli_output (vm, "tcp-transitory timeout: %dsec",
1209 sm->tcp_transitory_timeout);
1210 vlib_cli_output (vm, "icmp timeout: %dsec", sm->icmp_timeout);
1215 static clib_error_t *
1216 nat44_det_show_sessions_command_fn (vlib_main_t * vm,
1217 unformat_input_t * input,
1218 vlib_cli_command_t * cmd)
1220 snat_main_t *sm = &snat_main;
1222 snat_det_session_t *ses;
1225 vlib_cli_output (vm, "NAT44 deterministic sessions:");
1227 pool_foreach (dm, sm->det_maps,
1229 vec_foreach_index (i, dm->sessions)
1231 ses = vec_elt_at_index (dm->sessions, i);
1233 vlib_cli_output (vm, " %U", format_det_map_ses, dm, ses, &i);
1240 static clib_error_t *
1241 snat_det_close_session_out_fn (vlib_main_t * vm,
1242 unformat_input_t * input,
1243 vlib_cli_command_t * cmd)
1245 snat_main_t *sm = &snat_main;
1246 unformat_input_t _line_input, *line_input = &_line_input;
1247 ip4_address_t out_addr, ext_addr, in_addr;
1248 u32 out_port, ext_port;
1250 snat_det_session_t *ses;
1251 snat_det_out_key_t key;
1252 clib_error_t *error = 0;
1254 /* Get a line of input. */
1255 if (!unformat_user (input, unformat_line_input, line_input))
1258 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1260 if (unformat (line_input, "%U:%d %U:%d",
1261 unformat_ip4_address, &out_addr, &out_port,
1262 unformat_ip4_address, &ext_addr, &ext_port))
1266 error = clib_error_return (0, "unknown input '%U'",
1267 format_unformat_error, line_input);
1272 unformat_free (line_input);
1274 dm = snat_det_map_by_out (sm, &out_addr);
1276 vlib_cli_output (vm, "no match");
1279 snat_det_reverse (dm, &ext_addr, (u16) out_port, &in_addr);
1280 key.ext_host_addr = out_addr;
1281 key.ext_host_port = ntohs ((u16) ext_port);
1282 key.out_port = ntohs ((u16) out_port);
1283 ses = snat_det_get_ses_by_out (dm, &out_addr, key.as_u64);
1285 vlib_cli_output (vm, "no match");
1287 snat_det_ses_close (dm, ses);
1291 unformat_free (line_input);
1296 static clib_error_t *
1297 snat_det_close_session_in_fn (vlib_main_t * vm,
1298 unformat_input_t * input,
1299 vlib_cli_command_t * cmd)
1301 snat_main_t *sm = &snat_main;
1302 unformat_input_t _line_input, *line_input = &_line_input;
1303 ip4_address_t in_addr, ext_addr;
1304 u32 in_port, ext_port;
1306 snat_det_session_t *ses;
1307 snat_det_out_key_t key;
1308 clib_error_t *error = 0;
1310 /* Get a line of input. */
1311 if (!unformat_user (input, unformat_line_input, line_input))
1314 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1316 if (unformat (line_input, "%U:%d %U:%d",
1317 unformat_ip4_address, &in_addr, &in_port,
1318 unformat_ip4_address, &ext_addr, &ext_port))
1322 error = clib_error_return (0, "unknown input '%U'",
1323 format_unformat_error, line_input);
1328 unformat_free (line_input);
1330 dm = snat_det_map_by_user (sm, &in_addr);
1332 vlib_cli_output (vm, "no match");
1335 key.ext_host_addr = ext_addr;
1336 key.ext_host_port = ntohs ((u16) ext_port);
1338 snat_det_find_ses_by_in (dm, &in_addr, ntohs ((u16) in_port), key);
1340 vlib_cli_output (vm, "no match");
1342 snat_det_ses_close (dm, ses);
1346 unformat_free (line_input);
1354 * @cliexstart{set snat workers}
1355 * Set NAT workers if 2 or more workers available, use:
1356 * vpp# set snat workers 0-2,5
1359 VLIB_CLI_COMMAND (set_workers_command, static) = {
1360 .path = "set nat workers",
1361 .function = set_workers_command_fn,
1362 .short_help = "set nat workers <workers-list>",
1367 * @cliexstart{show nat workers}
1369 * vpp# show nat workers:
1375 VLIB_CLI_COMMAND (nat_show_workers_command, static) = {
1376 .path = "show nat workers",
1377 .short_help = "show nat workers",
1378 .function = nat_show_workers_commnad_fn,
1383 * @cliexstart{snat ipfix logging}
1384 * To enable NAT IPFIX logging use:
1385 * vpp# nat ipfix logging
1386 * To set IPFIX exporter use:
1387 * vpp# set ipfix exporter collector 10.10.10.3 src 10.10.10.1
1390 VLIB_CLI_COMMAND (snat_ipfix_logging_enable_disable_command, static) = {
1391 .path = "nat ipfix logging",
1392 .function = snat_ipfix_logging_enable_disable_command_fn,
1393 .short_help = "nat ipfix logging [domain <domain-id>] [src-port <port>] [disable]",
1398 * @cliexstart{nat addr-port-assignment-alg}
1399 * Set address and port assignment algorithm
1400 * For the MAP-E CE limit port choice based on PSID use:
1401 * vpp# nat addr-port-assignment-alg map-e psid 10 psid-offset 6 psid-len 6
1402 * To set standard (default) address and port assignment algorithm use:
1403 * vpp# nat addr-port-assignment-alg default
1406 VLIB_CLI_COMMAND (nat44_set_alloc_addr_and_port_alg_command, static) = {
1407 .path = "nat addr-port-assignment-alg",
1408 .short_help = "nat addr-port-assignment-alg <alg-name> [<alg-params>]",
1409 .function = nat44_set_alloc_addr_and_port_alg_command_fn,
1414 * @cliexstart{nat44 add address}
1415 * Add/delete NAT44 pool address.
1416 * To add NAT44 pool address use:
1417 * vpp# nat44 add address 172.16.1.3
1418 * vpp# nat44 add address 172.16.2.2 - 172.16.2.24
1419 * To add NAT44 pool address for specific tenant (identified by VRF id) use:
1420 * vpp# nat44 add address 172.16.1.3 tenant-vrf 10
1423 VLIB_CLI_COMMAND (add_address_command, static) = {
1424 .path = "nat44 add address",
1425 .short_help = "nat44 add address <ip4-range-start> [- <ip4-range-end>] "
1426 "[tenant-vrf <vrf-id>] [twice-nat] [del]",
1427 .function = add_address_command_fn,
1432 * @cliexstart{show nat44 addresses}
1433 * Show NAT44 pool addresses.
1434 * vpp# show nat44 addresses
1435 * NAT44 pool addresses:
1437 * tenant VRF independent
1446 * NAT44 twice-nat pool addresses:
1448 * tenant VRF independent
1454 VLIB_CLI_COMMAND (nat44_show_addresses_command, static) = {
1455 .path = "show nat44 addresses",
1456 .short_help = "show nat44 addresses",
1457 .function = nat44_show_addresses_command_fn,
1462 * @cliexstart{set interface nat44}
1463 * Enable/disable NAT44 feature on the interface.
1464 * To enable NAT44 feature with local network interface use:
1465 * vpp# set interface nat44 in GigabitEthernet0/8/0
1466 * To enable NAT44 feature with external network interface use:
1467 * vpp# set interface nat44 out GigabitEthernet0/a/0
1470 VLIB_CLI_COMMAND (set_interface_snat_command, static) = {
1471 .path = "set interface nat44",
1472 .function = snat_feature_command_fn,
1473 .short_help = "set interface nat44 in <intfc> out <intfc> [output-feature] "
1479 * @cliexstart{show nat44 interfaces}
1480 * Show interfaces with NAT44 feature.
1481 * vpp# show nat44 interfaces
1483 * GigabitEthernet0/8/0 in
1484 * GigabitEthernet0/a/0 out
1487 VLIB_CLI_COMMAND (nat44_show_interfaces_command, static) = {
1488 .path = "show nat44 interfaces",
1489 .short_help = "show nat44 interfaces",
1490 .function = nat44_show_interfaces_command_fn,
1495 * @cliexstart{nat44 add static mapping}
1496 * Static mapping allows hosts on the external network to initiate connection
1497 * to to the local network host.
1498 * To create static mapping between local host address 10.0.0.3 port 6303 and
1499 * external address 4.4.4.4 port 3606 for TCP protocol use:
1500 * vpp# nat44 add static mapping tcp local 10.0.0.3 6303 external 4.4.4.4 3606
1501 * If not runnig "static mapping only" NAT plugin mode use before:
1502 * vpp# nat44 add address 4.4.4.4
1503 * To create static mapping between local and external address use:
1504 * vpp# nat44 add static mapping local 10.0.0.3 external 4.4.4.4
1507 VLIB_CLI_COMMAND (add_static_mapping_command, static) = {
1508 .path = "nat44 add static mapping",
1509 .function = add_static_mapping_command_fn,
1511 "nat44 add static mapping tcp|udp|icmp local <addr> [<port>] "
1512 "external <addr> [<port>] [vrf <table-id>] [twice-nat] [out2in-only] [del]",
1517 * @cliexstart{nat44 add identity mapping}
1518 * Identity mapping translate an IP address to itself.
1519 * To create identity mapping for address 10.0.0.3 port 6303 for TCP protocol
1521 * vpp# nat44 add identity mapping 10.0.0.3 tcp 6303
1522 * To create identity mapping for address 10.0.0.3 use:
1523 * vpp# nat44 add identity mapping 10.0.0.3
1524 * To create identity mapping for DHCP addressed interface use:
1525 * vpp# nat44 add identity mapping GigabitEthernet0/a/0 tcp 3606
1528 VLIB_CLI_COMMAND (add_identity_mapping_command, static) = {
1529 .path = "nat44 add identity mapping",
1530 .function = add_identity_mapping_command_fn,
1531 .short_help = "nat44 add identity mapping <interface>|<ip4-addr> "
1532 "[<protocol> <port>] [vrf <table-id>] [del]",
1537 * @cliexstart{nat44 add load-balancing static mapping}
1538 * Service load balancing using NAT44
1539 * To add static mapping with load balancing for service with external IP
1540 * address 1.2.3.4 and TCP port 80 and mapped to 2 local servers
1541 * 10.100.10.10:8080 and 10.100.10.20:8080 with probability 80% resp. 20% use:
1542 * vpp# nat44 add load-balancing static mapping protocol tcp external 1.2.3.4:80 local 10.100.10.10:8080 probability 80 local 10.100.10.20:8080 probability 20
1545 VLIB_CLI_COMMAND (add_lb_static_mapping_command, static) = {
1546 .path = "nat44 add load-balancing static mapping",
1547 .function = add_lb_static_mapping_command_fn,
1549 "nat44 add load-balancing static mapping protocol tcp|udp "
1550 "external <addr>:<port> local <addr>:<port> probability <n> [twice-nat] "
1551 "[vrf <table-id>] [out2in-only] [del]",
1556 * @cliexstart{show nat44 static mappings}
1557 * Show NAT44 static mappings.
1558 * vpp# show nat44 static mappings
1559 * NAT44 static mappings:
1560 * local 10.0.0.3 external 4.4.4.4 vrf 0
1561 * tcp local 192.168.0.4:6303 external 4.4.4.3:3606 vrf 0
1562 * tcp vrf 0 external 1.2.3.4:80 out2in-only
1563 * local 10.100.10.10:8080 probability 80
1564 * local 10.100.10.20:8080 probability 20
1565 * tcp local 10.100.3.8:8080 external 169.10.10.1:80 vrf 0 twice-nat
1566 * tcp local 10.0.0.10:3603 external GigabitEthernet0/a/0:6306 vrf 10
1569 VLIB_CLI_COMMAND (nat44_show_static_mappings_command, static) = {
1570 .path = "show nat44 static mappings",
1571 .short_help = "show nat44 static mappings",
1572 .function = nat44_show_static_mappings_command_fn,
1577 * @cliexstart{nat44 add interface address}
1578 * Use NAT44 pool address from specific interfce
1579 * To add NAT44 pool address from specific interface use:
1580 * vpp# nat44 add interface address GigabitEthernet0/8/0
1583 VLIB_CLI_COMMAND (snat_add_interface_address_command, static) = {
1584 .path = "nat44 add interface address",
1585 .short_help = "nat44 add interface address <interface> [twice-nat] [del]",
1586 .function = snat_add_interface_address_command_fn,
1591 * @cliexstart{show nat44 interface address}
1592 * Show NAT44 pool address interfaces
1593 * vpp# show nat44 interface address
1594 * NAT44 pool address interfaces:
1595 * GigabitEthernet0/a/0
1596 * NAT44 twice-nat pool address interfaces:
1597 * GigabitEthernet0/8/0
1600 VLIB_CLI_COMMAND (nat44_show_interface_address_command, static) = {
1601 .path = "show nat44 interface address",
1602 .short_help = "show nat44 interface address",
1603 .function = nat44_show_interface_address_command_fn,
1608 * @cliexstart{show nat44 sessions}
1609 * Show NAT44 sessions.
1612 VLIB_CLI_COMMAND (nat44_show_sessions_command, static) = {
1613 .path = "show nat44 sessions",
1614 .short_help = "show nat44 sessions [detail]",
1615 .function = nat44_show_sessions_command_fn,
1620 * @cliexstart{nat44 del session}
1621 * To administratively delete NAT44 session by inside address and port use:
1622 * vpp# nat44 del session in 10.0.0.3:6303 tcp
1623 * To administratively delete NAT44 session by outside address and port use:
1624 * vpp# nat44 del session out 1.0.0.3:6033 udp
1627 VLIB_CLI_COMMAND (nat44_del_session_command, static) = {
1628 .path = "nat44 del session",
1629 .short_help = "nat44 del session in|out <addr>:<port> tcp|udp|icmp [vrf <id>]",
1630 .function = nat44_del_session_command_fn,
1635 * @cliexstart{nat44 forwarding}
1636 * Enable or disable forwarding
1637 * Forward packets which don't match existing translation
1638 * or static mapping instead of dropping them.
1639 * To enable forwarding, use:
1640 * vpp# nat44 forwarding enable
1641 * To disable forwarding, use:
1642 * vpp# nat44 forwarding disable
1645 VLIB_CLI_COMMAND (snat_forwarding_set_command, static) = {
1646 .path = "nat44 forwarding",
1647 .short_help = "nat44 forwarding enable|disable",
1648 .function = snat_forwarding_set_command_fn,
1653 * @cliexstart{nat44 deterministic add}
1654 * Create bijective mapping of inside address to outside address and port range
1655 * pairs, with the purpose of enabling deterministic NAT to reduce logging in
1657 * To create deterministic mapping between inside network 10.0.0.0/18 and
1658 * outside network 1.1.1.0/30 use:
1659 * # vpp# nat44 deterministic add in 10.0.0.0/18 out 1.1.1.0/30
1662 VLIB_CLI_COMMAND (snat_det_map_command, static) = {
1663 .path = "nat44 deterministic add",
1664 .short_help = "nat44 deterministic add in <addr>/<plen> out <addr>/<plen> [del]",
1665 .function = snat_det_map_command_fn,
1670 * @cliexpstart{show nat44 deterministic mappings}
1671 * Show NAT44 deterministic mappings
1672 * vpp# show nat44 deterministic mappings
1673 * NAT44 deterministic mappings:
1674 * in 10.0.0.0/24 out 1.1.1.1/32
1675 * outside address sharing ratio: 256
1676 * number of ports per inside host: 252
1677 * sessions number: 0
1680 VLIB_CLI_COMMAND (nat44_det_show_mappings_command, static) = {
1681 .path = "show nat44 deterministic mappings",
1682 .short_help = "show nat44 deterministic mappings",
1683 .function = nat44_det_show_mappings_command_fn,
1688 * @cliexstart{nat44 deterministic forward}
1689 * Return outside address and port range from inside address for deterministic
1691 * To obtain outside address and port of inside host use:
1692 * vpp# nat44 deterministic forward 10.0.0.2
1693 * 1.1.1.0:<1054-1068>
1696 VLIB_CLI_COMMAND (snat_det_forward_command, static) = {
1697 .path = "nat44 deterministic forward",
1698 .short_help = "nat44 deterministic forward <addr>",
1699 .function = snat_det_forward_command_fn,
1704 * @cliexstart{nat44 deterministic reverse}
1705 * Return inside address from outside address and port for deterministic NAT.
1706 * To obtain inside host address from outside address and port use:
1707 * #vpp nat44 deterministic reverse 1.1.1.1:1276
1711 VLIB_CLI_COMMAND (snat_det_reverse_command, static) = {
1712 .path = "nat44 deterministic reverse",
1713 .short_help = "nat44 deterministic reverse <addr>:<port>",
1714 .function = snat_det_reverse_command_fn,
1719 * @cliexstart{set nat44 deterministic timeout}
1720 * Set values of timeouts for deterministic NAT (in seconds), use:
1721 * vpp# set nat44 deterministic timeout udp 120 tcp-established 7500
1722 * tcp-transitory 250 icmp 90
1723 * To reset default values use:
1724 * vpp# set nat44 deterministic timeout reset
1727 VLIB_CLI_COMMAND (set_timeout_command, static) = {
1728 .path = "set nat44 deterministic timeout",
1729 .function = set_timeout_command_fn,
1731 "set nat44 deterministic timeout [udp <sec> | tcp-established <sec> "
1732 "tcp-transitory <sec> | icmp <sec> | reset]",
1737 * @cliexstart{show nat44 deterministic timeouts}
1738 * Show values of timeouts for deterministic NAT.
1739 * vpp# show nat44 deterministic timeouts
1740 * udp timeout: 300sec
1741 * tcp-established timeout: 7440sec
1742 * tcp-transitory timeout: 240sec
1743 * icmp timeout: 60sec
1746 VLIB_CLI_COMMAND (nat44_det_show_timeouts_command, static) = {
1747 .path = "show nat44 deterministic timeouts",
1748 .short_help = "show nat44 deterministic timeouts",
1749 .function = nat44_det_show_timeouts_command_fn,
1754 * @cliexstart{show nat44 deterministic sessions}
1755 * Show NAT44 deterministic sessions.
1756 * vpp# show nat44 deterministic sessions
1757 * NAT44 deterministic sessions:
1758 * in 10.0.0.3:3005 out 1.1.1.2:1146 external host 172.16.1.2:3006 state: udp-active expire: 306
1759 * in 10.0.0.3:3000 out 1.1.1.2:1141 external host 172.16.1.2:3001 state: udp-active expire: 306
1760 * in 10.0.0.4:3005 out 1.1.1.2:1177 external host 172.16.1.2:3006 state: udp-active expire: 306
1763 VLIB_CLI_COMMAND (nat44_det_show_sessions_command, static) = {
1764 .path = "show nat44 deterministic sessions",
1765 .short_help = "show nat44 deterministic sessions",
1766 .function = nat44_det_show_sessions_command_fn,
1771 * @cliexstart{nat44 deterministic close session out}
1772 * Close session using outside ip address and port
1773 * and external ip address and port, use:
1774 * vpp# nat44 deterministic close session out 1.1.1.1:1276 2.2.2.2:2387
1777 VLIB_CLI_COMMAND (snat_det_close_sesion_out_command, static) = {
1778 .path = "nat44 deterministic close session out",
1779 .short_help = "nat44 deterministic close session out "
1780 "<out_addr>:<out_port> <ext_addr>:<ext_port>",
1781 .function = snat_det_close_session_out_fn,
1786 * @cliexstart{nat44 deterministic close session in}
1787 * Close session using inside ip address and port
1788 * and external ip address and port, use:
1789 * vpp# nat44 deterministic close session in 3.3.3.3:3487 2.2.2.2:2387
1792 VLIB_CLI_COMMAND (snat_det_close_session_in_command, static) = {
1793 .path = "nat44 deterministic close session in",
1794 .short_help = "nat44 deterministic close session in "
1795 "<in_addr>:<in_port> <ext_addr>:<ext_port>",
1796 .function = snat_det_close_session_in_fn,
1802 * fd.io coding-style-patch-verification: ON
1805 * eval: (c-set-style "gnu")