acl-plugin: multicore: CSIT c100k 2-core stateful ACL test does not pass (VPP-912)
[vpp.git] / src / plugins / snat / nat64_cli.c
1 /*
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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 /**
16  * @file
17  * @brief NAT64 CLI
18  */
19
20 #include <snat/nat64.h>
21 #include <snat/snat.h>
22 #include <vnet/fib/fib_table.h>
23
24 static clib_error_t *
25 nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
26                                     unformat_input_t * input,
27                                     vlib_cli_command_t * cmd)
28 {
29   nat64_main_t *nm = &nat64_main;
30   unformat_input_t _line_input, *line_input = &_line_input;
31   ip4_address_t start_addr, end_addr, this_addr;
32   u32 start_host_order, end_host_order;
33   int i, count, rv;
34   u32 vrf_id = ~0;
35   u8 is_add = 1;
36   clib_error_t *error = 0;
37
38   if (nm->is_disabled)
39     return clib_error_return (0,
40                               "NAT64 disabled, multi thread not supported");
41
42   /* Get a line of input. */
43   if (!unformat_user (input, unformat_line_input, line_input))
44     return 0;
45
46   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
47     {
48       if (unformat (line_input, "%U - %U",
49                     unformat_ip4_address, &start_addr,
50                     unformat_ip4_address, &end_addr))
51         ;
52       else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
53         ;
54       else if (unformat (line_input, "%U", unformat_ip4_address, &start_addr))
55         end_addr = start_addr;
56       else if (unformat (line_input, "del"))
57         is_add = 0;
58       else
59         {
60           error = clib_error_return (0, "unknown input '%U'",
61                                      format_unformat_error, line_input);
62           goto done;
63         }
64     }
65
66   start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
67   end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
68
69   if (end_host_order < start_host_order)
70     {
71       error = clib_error_return (0, "end address less than start address");
72       goto done;
73     }
74
75   count = (end_host_order - start_host_order) + 1;
76   this_addr = start_addr;
77
78   for (i = 0; i < count; i++)
79     {
80       rv = nat64_add_del_pool_addr (&this_addr, vrf_id, is_add);
81
82       switch (rv)
83         {
84         case VNET_API_ERROR_NO_SUCH_ENTRY:
85           error =
86             clib_error_return (0, "NAT64 pool address %U not exist.",
87                                format_ip4_address, &this_addr);
88           goto done;
89         case VNET_API_ERROR_VALUE_EXIST:
90           error =
91             clib_error_return (0, "NAT64 pool address %U exist.",
92                                format_ip4_address, &this_addr);
93           goto done;
94         default:
95           break;
96
97         }
98       increment_v4_address (&this_addr);
99     }
100
101 done:
102   unformat_free (line_input);
103
104   return error;
105 }
106
107 static int
108 nat64_cli_pool_walk (snat_address_t * ap, void *ctx)
109 {
110   vlib_main_t *vm = ctx;
111
112   if (ap->fib_index != ~0)
113     {
114       fib_table_t *fib;
115       fib = fib_table_get (ap->fib_index, FIB_PROTOCOL_IP6);
116       if (!fib)
117         return -1;
118       vlib_cli_output (vm, " %U tenant VRF: %u", format_ip4_address,
119                        &ap->addr, fib->ft_table_id);
120     }
121   else
122     vlib_cli_output (vm, " %U", format_ip4_address, &ap->addr);
123
124   return 0;
125 }
126
127 static clib_error_t *
128 nat64_show_pool_command_fn (vlib_main_t * vm,
129                             unformat_input_t * input,
130                             vlib_cli_command_t * cmd)
131 {
132   nat64_main_t *nm = &nat64_main;
133
134   if (nm->is_disabled)
135     return clib_error_return (0,
136                               "NAT64 disabled, multi thread not supported");
137
138   vlib_cli_output (vm, "NAT64 pool:");
139   nat64_pool_addr_walk (nat64_cli_pool_walk, vm);
140
141   return 0;
142 }
143
144 static clib_error_t *
145 nat64_interface_feature_command_fn (vlib_main_t * vm,
146                                     unformat_input_t *
147                                     input, vlib_cli_command_t * cmd)
148 {
149   nat64_main_t *nm = &nat64_main;
150   unformat_input_t _line_input, *line_input = &_line_input;
151   vnet_main_t *vnm = vnet_get_main ();
152   clib_error_t *error = 0;
153   u32 sw_if_index;
154   u32 *inside_sw_if_indices = 0;
155   u32 *outside_sw_if_indices = 0;
156   u8 is_add = 1;
157   int i, rv;
158
159   if (nm->is_disabled)
160     return clib_error_return (0,
161                               "NAT64 disabled, multi thread not supported");
162
163   /* Get a line of input. */
164   if (!unformat_user (input, unformat_line_input, line_input))
165     return 0;
166
167   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
168     {
169       if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
170                     vnm, &sw_if_index))
171         vec_add1 (inside_sw_if_indices, sw_if_index);
172       else if (unformat (line_input, "out %U", unformat_vnet_sw_interface,
173                          vnm, &sw_if_index))
174         vec_add1 (outside_sw_if_indices, sw_if_index);
175       else if (unformat (line_input, "del"))
176         is_add = 0;
177       else
178         {
179           error = clib_error_return (0, "unknown input '%U'",
180                                      format_unformat_error, line_input);
181           goto done;
182         }
183     }
184
185   if (vec_len (inside_sw_if_indices))
186     {
187       for (i = 0; i < vec_len (inside_sw_if_indices); i++)
188         {
189           sw_if_index = inside_sw_if_indices[i];
190           rv = nat64_add_del_interface (sw_if_index, 1, is_add);
191           switch (rv)
192             {
193             case VNET_API_ERROR_NO_SUCH_ENTRY:
194               error =
195                 clib_error_return (0, "%U NAT64 feature not enabled.",
196                                    format_vnet_sw_interface_name, vnm,
197                                    vnet_get_sw_interface (vnm, sw_if_index));
198               goto done;
199             case VNET_API_ERROR_VALUE_EXIST:
200               error =
201                 clib_error_return (0, "%U NAT64 feature already enabled.",
202                                    format_vnet_sw_interface_name, vnm,
203                                    vnet_get_sw_interface (vnm, sw_if_index));
204               goto done;
205             case VNET_API_ERROR_INVALID_VALUE:
206             case VNET_API_ERROR_INVALID_VALUE_2:
207               error =
208                 clib_error_return (0,
209                                    "%U NAT64 feature enable/disable failed.",
210                                    format_vnet_sw_interface_name, vnm,
211                                    vnet_get_sw_interface (vnm, sw_if_index));
212               goto done;
213             default:
214               break;
215
216             }
217         }
218     }
219
220   if (vec_len (outside_sw_if_indices))
221     {
222       for (i = 0; i < vec_len (outside_sw_if_indices); i++)
223         {
224           sw_if_index = outside_sw_if_indices[i];
225           rv = nat64_add_del_interface (sw_if_index, 0, is_add);
226           switch (rv)
227             {
228             case VNET_API_ERROR_NO_SUCH_ENTRY:
229               error =
230                 clib_error_return (0, "%U NAT64 feature not enabled.",
231                                    format_vnet_sw_interface_name, vnm,
232                                    vnet_get_sw_interface (vnm, sw_if_index));
233               goto done;
234             case VNET_API_ERROR_VALUE_EXIST:
235               error =
236                 clib_error_return (0, "%U NAT64 feature already enabled.",
237                                    format_vnet_sw_interface_name, vnm,
238                                    vnet_get_sw_interface (vnm, sw_if_index));
239               goto done;
240             case VNET_API_ERROR_INVALID_VALUE:
241             case VNET_API_ERROR_INVALID_VALUE_2:
242               error =
243                 clib_error_return (0,
244                                    "%U NAT64 feature enable/disable failed.",
245                                    format_vnet_sw_interface_name, vnm,
246                                    vnet_get_sw_interface (vnm, sw_if_index));
247               goto done;
248             default:
249               break;
250
251             }
252         }
253     }
254
255 done:
256   unformat_free (line_input);
257   vec_free (inside_sw_if_indices);
258   vec_free (outside_sw_if_indices);
259
260   return error;
261 }
262
263 static int
264 nat64_cli_interface_walk (snat_interface_t * i, void *ctx)
265 {
266   vlib_main_t *vm = ctx;
267   vnet_main_t *vnm = vnet_get_main ();
268
269   vlib_cli_output (vm, " %U %s", format_vnet_sw_interface_name, vnm,
270                    vnet_get_sw_interface (vnm, i->sw_if_index),
271                    i->is_inside ? "in" : "out");
272   return 0;
273 }
274
275 static clib_error_t *
276 nat64_show_interfaces_command_fn (vlib_main_t * vm,
277                                   unformat_input_t *
278                                   input, vlib_cli_command_t * cmd)
279 {
280   nat64_main_t *nm = &nat64_main;
281
282   if (nm->is_disabled)
283     return clib_error_return (0,
284                               "NAT64 disabled, multi thread not supported");
285
286   vlib_cli_output (vm, "NAT64 interfaces:");
287   nat64_interfaces_walk (nat64_cli_interface_walk, vm);
288
289   return 0;
290 }
291
292 static clib_error_t *
293 nat64_add_del_static_bib_command_fn (vlib_main_t *
294                                      vm,
295                                      unformat_input_t
296                                      * input, vlib_cli_command_t * cmd)
297 {
298   nat64_main_t *nm = &nat64_main;
299   unformat_input_t _line_input, *line_input = &_line_input;
300   clib_error_t *error = 0;
301   u8 is_add = 1;
302   ip6_address_t in_addr;
303   ip4_address_t out_addr;
304   u16 in_port = 0;
305   u16 out_port = 0;
306   u32 vrf_id = 0;
307   snat_protocol_t proto = 0;
308   u8 p = 0;
309   int rv;
310
311   if (nm->is_disabled)
312     return clib_error_return (0,
313                               "NAT64 disabled, multi thread not supported");
314
315   if (!unformat_user (input, unformat_line_input, line_input))
316     return 0;
317
318   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
319     {
320       if (unformat (line_input, "%U %u", unformat_ip6_address,
321                     &in_addr, &in_port))
322         ;
323       else if (unformat (line_input, "%U %u", unformat_ip4_address,
324                          &out_addr, &out_port))
325         ;
326       else if (unformat (line_input, "vrf %u", &vrf_id))
327         ;
328       else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
329         ;
330       else if (unformat (line_input, "del"))
331         is_add = 0;
332       else
333         {
334           error = clib_error_return (0, "unknown input: '%U'",
335                                      format_unformat_error, line_input);
336           goto done;
337         }
338     }
339
340   if (!in_port)
341     {
342       error = clib_error_return (0, "inside port and address  must be set");
343       goto done;
344     }
345
346   if (!out_port)
347     {
348       error = clib_error_return (0, "outside port and address  must be set");
349       goto done;
350     }
351
352   p = snat_proto_to_ip_proto (proto);
353
354   rv =
355     nat64_add_del_static_bib_entry (&in_addr, &out_addr, in_port, out_port, p,
356                                     vrf_id, is_add);
357
358   switch (rv)
359     {
360     case VNET_API_ERROR_NO_SUCH_ENTRY:
361       error = clib_error_return (0, "NAT64 BIB entry not exist.");
362       goto done;
363     case VNET_API_ERROR_VALUE_EXIST:
364       error = clib_error_return (0, "NAT64 BIB entry exist.");
365       goto done;
366     case VNET_API_ERROR_UNSPECIFIED:
367       error = clib_error_return (0, "Crerate NAT64 BIB entry failed.");
368       goto done;
369     case VNET_API_ERROR_INVALID_VALUE:
370       error =
371         clib_error_return (0, "Outside addres %U and port %u already in use.",
372                            format_ip4_address, &out_addr, out_port);
373       goto done;
374     default:
375       break;
376     }
377
378 done:
379   unformat_free (line_input);
380
381   return error;
382 }
383
384 static int
385 nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
386 {
387   vlib_main_t *vm = ctx;
388   fib_table_t *fib;
389
390   fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
391   if (!fib)
392     return -1;
393
394   vlib_cli_output (vm, " %U %u %U %u %U vrf %u %s %u sessions",
395                    format_ip6_address, &bibe->in_addr,
396                    clib_net_to_host_u16 (bibe->in_port), format_ip4_address,
397                    &bibe->out_addr, clib_net_to_host_u16 (bibe->out_port),
398                    format_snat_protocol, bibe->proto, fib->ft_table_id,
399                    bibe->is_static ? "static" : "dynamic", bibe->ses_num);
400   return 0;
401 }
402
403 static clib_error_t *
404 nat64_show_bib_command_fn (vlib_main_t * vm,
405                            unformat_input_t * input, vlib_cli_command_t * cmd)
406 {
407   nat64_main_t *nm = &nat64_main;
408   unformat_input_t _line_input, *line_input = &_line_input;
409   clib_error_t *error = 0;
410   snat_protocol_t proto = 0;
411
412   if (nm->is_disabled)
413     return clib_error_return (0,
414                               "NAT64 disabled, multi thread not supported");
415
416   if (!unformat_user (input, unformat_line_input, line_input))
417     return 0;
418
419   if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
420     ;
421   else
422     {
423       error = clib_error_return (0, "unknown input: '%U'",
424                                  format_unformat_error, line_input);
425       goto done;
426     }
427
428   vlib_cli_output (vm, "NAT64 %U BIB:", format_snat_protocol, proto);
429   nat64_db_bib_walk (&nm->db, proto, nat64_cli_bib_walk, vm);
430
431 done:
432   unformat_free (line_input);
433
434   return error;
435 }
436
437 static clib_error_t *
438 nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
439                                vlib_cli_command_t * cmd)
440 {
441   nat64_main_t *nm = &nat64_main;
442   unformat_input_t _line_input, *line_input = &_line_input;
443   clib_error_t *error = 0;
444   u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
445
446   tcp_trans = nat64_get_tcp_trans_timeout ();
447   tcp_est = nat64_get_tcp_est_timeout ();
448   tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout ();
449
450   if (nm->is_disabled)
451     return clib_error_return (0,
452                               "NAT64 disabled, multi thread not supported");
453
454   if (!unformat_user (input, unformat_line_input, line_input))
455     return 0;
456
457   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
458     {
459       if (unformat (line_input, "udp %u", &timeout))
460         {
461           if (nat64_set_udp_timeout (timeout))
462             {
463               error = clib_error_return (0, "Invalid UDP timeout value");
464               goto done;
465             }
466         }
467       else if (unformat (line_input, "icmp %u", &timeout))
468         {
469           if (nat64_set_icmp_timeout (timeout))
470             {
471               error = clib_error_return (0, "Invalid ICMP timeout value");
472               goto done;
473             }
474         }
475       else if (unformat (line_input, "tcp-trans %u", &tcp_trans))
476         {
477           if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
478             {
479               error =
480                 clib_error_return (0, "Invalid TCP transitory tiemout value");
481               goto done;
482             }
483         }
484       else if (unformat (line_input, "tcp-est %u", &tcp_est))
485         {
486           if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
487             {
488               error =
489                 clib_error_return (0,
490                                    "Invalid TCP established tiemout value");
491               goto done;
492             }
493         }
494       else
495         if (unformat (line_input, "tcp-incoming-syn %u", &tcp_incoming_syn))
496         {
497           if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
498             {
499               error =
500                 clib_error_return (0,
501                                    "Invalid TCP incoming SYN tiemout value");
502               goto done;
503             }
504         }
505       else if (unformat (line_input, "reset"))
506         {
507           nat64_set_udp_timeout (0);
508           nat64_set_icmp_timeout (0);
509           nat64_set_tcp_timeouts (0, 0, 0);
510         }
511       else
512         {
513           error = clib_error_return (0, "unknown input '%U'",
514                                      format_unformat_error, line_input);
515           goto done;
516         }
517     }
518
519 done:
520   unformat_free (line_input);
521
522   return error;
523 }
524
525 static clib_error_t *
526 nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
527                                 vlib_cli_command_t * cmd)
528 {
529   nat64_main_t *nm = &nat64_main;
530
531   if (nm->is_disabled)
532     return clib_error_return (0,
533                               "NAT64 disabled, multi thread not supported");
534
535   vlib_cli_output (vm, "NAT64 session timeouts:");
536   vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ());
537   vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ());
538   vlib_cli_output (vm, " TCP transitory %usec",
539                    nat64_get_tcp_trans_timeout ());
540   vlib_cli_output (vm, " TCP established %usec",
541                    nat64_get_tcp_est_timeout ());
542   vlib_cli_output (vm, " TCP incoming SYN %usec",
543                    nat64_get_tcp_incoming_syn_timeout ());
544
545   return 0;
546 }
547
548 static int
549 nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *ctx)
550 {
551   vlib_main_t *vm = ctx;
552   nat64_main_t *nm = &nat64_main;
553   nat64_db_bib_entry_t *bibe;
554   fib_table_t *fib;
555
556   bibe = nat64_db_bib_entry_by_index (&nm->db, ste->proto, ste->bibe_index);
557   if (!bibe)
558     return -1;
559
560   fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
561   if (!fib)
562     return -1;
563
564   u32 vrf_id = fib->ft_table_id;
565
566   if (ste->proto == SNAT_PROTOCOL_ICMP)
567     vlib_cli_output (vm, " %U %U %u %U %U %u %U vrf %u",
568                      format_ip6_address, &bibe->in_addr,
569                      format_ip6_address, &ste->in_r_addr,
570                      clib_net_to_host_u16 (bibe->in_port),
571                      format_ip4_address, &bibe->out_addr,
572                      format_ip4_address, &ste->out_r_addr,
573                      clib_net_to_host_u16 (bibe->out_port),
574                      format_snat_protocol, bibe->proto, vrf_id);
575   else
576     vlib_cli_output (vm, " %U %u %U %u %U %u %U %u %U vrf %u",
577                      format_ip6_address, &bibe->in_addr,
578                      clib_net_to_host_u16 (bibe->in_port),
579                      format_ip6_address, &ste->in_r_addr,
580                      clib_net_to_host_u16 (ste->r_port),
581                      format_ip4_address, &bibe->out_addr,
582                      clib_net_to_host_u16 (bibe->out_port),
583                      format_ip4_address, &ste->out_r_addr,
584                      clib_net_to_host_u16 (ste->r_port),
585                      format_snat_protocol, bibe->proto, vrf_id);
586   return 0;
587 }
588
589 static clib_error_t *
590 nat64_show_st_command_fn (vlib_main_t * vm,
591                           unformat_input_t * input, vlib_cli_command_t * cmd)
592 {
593   nat64_main_t *nm = &nat64_main;
594   unformat_input_t _line_input, *line_input = &_line_input;
595   clib_error_t *error = 0;
596   snat_protocol_t proto = 0;
597
598   if (nm->is_disabled)
599     return clib_error_return (0,
600                               "NAT64 disabled, multi thread not supported");
601
602   if (!unformat_user (input, unformat_line_input, line_input))
603     return 0;
604
605   if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
606     ;
607   else
608     {
609       error = clib_error_return (0, "unknown input: '%U'",
610                                  format_unformat_error, line_input);
611       goto done;
612     }
613
614   vlib_cli_output (vm, "NAT64 %U session table:", format_snat_protocol,
615                    proto);
616   nat64_db_st_walk (&nm->db, proto, nat64_cli_st_walk, vm);
617
618 done:
619   unformat_free (line_input);
620
621   return error;
622 }
623
624 static clib_error_t *
625 nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
626                                  vlib_cli_command_t * cmd)
627 {
628   nat64_main_t *nm = &nat64_main;
629   clib_error_t *error = 0;
630   unformat_input_t _line_input, *line_input = &_line_input;
631   u8 is_add = 1;
632   u32 vrf_id = 0;
633   ip6_address_t prefix;
634   u32 plen = 0;
635   int rv;
636
637   if (nm->is_disabled)
638     return clib_error_return (0,
639                               "NAT64 disabled, multi thread not supported");
640
641   if (!unformat_user (input, unformat_line_input, line_input))
642     return 0;
643
644   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
645     {
646       if (unformat
647           (line_input, "%U/%u", unformat_ip6_address, &prefix, &plen))
648         ;
649       else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
650         ;
651       else if (unformat (line_input, "del"))
652         is_add = 0;
653       else
654         {
655           error = clib_error_return (0, "unknown input: '%U'",
656                                      format_unformat_error, line_input);
657           goto done;
658         }
659     }
660
661   if (!plen)
662     {
663       error = clib_error_return (0, "NAT64 prefix must be set.");
664       goto done;
665     }
666
667   rv = nat64_add_del_prefix (&prefix, (u8) plen, vrf_id, is_add);
668
669   switch (rv)
670     {
671     case VNET_API_ERROR_NO_SUCH_ENTRY:
672       error = clib_error_return (0, "NAT64 prefix not exist.");
673       goto done;
674     case VNET_API_ERROR_INVALID_VALUE:
675       error = clib_error_return (0, "Invalid prefix length.");
676       goto done;
677     default:
678       break;
679     }
680
681 done:
682   unformat_free (line_input);
683
684   return error;
685 }
686
687 static int
688 nat64_cli_prefix_walk (nat64_prefix_t * p, void *ctx)
689 {
690   vlib_main_t *vm = ctx;
691
692   vlib_cli_output (vm, " %U/%u tenant-vrf %u",
693                    format_ip6_address, &p->prefix, p->plen, p->vrf_id);
694
695   return 0;
696 }
697
698 static clib_error_t *
699 nat64_show_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
700                               vlib_cli_command_t * cmd)
701 {
702   nat64_main_t *nm = &nat64_main;
703
704   if (nm->is_disabled)
705     return clib_error_return (0,
706                               "NAT64 disabled, multi thread not supported");
707
708   vlib_cli_output (vm, "NAT64 prefix:");
709   nat64_prefix_walk (nat64_cli_prefix_walk, vm);
710
711   return 0;
712 }
713
714 /* *INDENT-OFF* */
715
716 /*?
717  * @cliexpar
718  * @cliexstart{nat64 add pool address}
719  * Add/delete NAT64 pool address.
720  * To add single NAT64 pool address use:
721  *  vpp# nat64 add pool address 10.1.1.10
722  * To add NAT64 pool address range use:
723  *  vpp# nat64 add pool address 10.1.1.2 - 10.1.1.5
724  * To add NAT64 pool address for specific tenant use:
725  *  vpp# nat64 add pool address 10.1.1.100 tenant-vrf 100
726  * @cliexend
727 ?*/
728 VLIB_CLI_COMMAND (nat64_add_pool_address_command, static) = {
729   .path = "nat64 add pool address",
730   .short_help = "nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
731                 "[tenant-vrf <vrf-id>] [del]",
732   .function = nat64_add_del_pool_addr_command_fn,
733 };
734
735 /*?
736  * @cliexpar
737  * @cliexstart{show nat64 pool}
738  * Show NAT64 pool.
739  *  vpp# show nat64 pool
740  *  NAT64 pool:
741  *   10.1.1.3 tenant VRF: 0
742  *   10.1.1.10 tenant VRF: 10
743  * @cliexend
744 ?*/
745 VLIB_CLI_COMMAND (show_nat64_pool_command, static) = {
746   .path = "show nat64 pool",
747   .short_help = "show nat64 pool",
748   .function = nat64_show_pool_command_fn,
749 };
750
751 /*?
752  * @cliexpar
753  * @cliexstart{set interface nat64}
754  * Enable/disable NAT64 feature on the interface.
755  * To enable NAT64 feature with local (IPv6) network interface
756  * GigabitEthernet0/8/0 and external (IPv4) network interface
757  * GigabitEthernet0/a/0 use:
758  *  vpp# set interface nat64 in GigabitEthernet0/8/0 out GigabitEthernet0/a/0
759  * @cliexend
760 ?*/
761 VLIB_CLI_COMMAND (set_interface_nat64_command, static) = {
762   .path = "set interface nat64",
763   .short_help = "set interface nat64 in|out <intfc> [del]",
764   .function = nat64_interface_feature_command_fn,
765 };
766
767 /*?
768  * @cliexpar
769  * @cliexstart{show nat64 interfaces}
770  * Show interfaces with NAT64 feature.
771  * To show interfaces with NAT64 feature use:
772  *  vpp# show nat64 interfaces
773  *  NAT64 interfaces:
774  *   GigabitEthernet0/8/0 in
775  *   GigabitEthernet0/a/0 out
776  * @cliexend
777 ?*/
778 VLIB_CLI_COMMAND (show_nat64_interfaces_command, static) = {
779   .path = "show nat64 interfaces",
780   .short_help = "show nat64 interfaces",
781   .function = nat64_show_interfaces_command_fn,
782 };
783
784 /*?
785  * @cliexpar
786  * @cliexstart{nat64 add static bib}
787  * Add/delete NAT64 static BIB entry.
788  * To create NAT64 satatic BIB entry use:
789  *  vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp
790  *  vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10
791  * @cliexend
792 ?*/
793 VLIB_CLI_COMMAND (nat64_add_del_static_bib_command, static) = {
794   .path = "nat64 add static bib",
795   .short_help = "nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
796                 "tcp|udp|icmp [vfr <table-id>] [del]",
797   .function = nat64_add_del_static_bib_command_fn,
798 };
799
800 /*?
801  * @cliexpar
802  * @cliexstart{show nat64 bib}
803  * Show NAT64 BIB entries.
804  * To show NAT64 TCP BIB entries use:
805  *  vpp# show nat64 bib tcp
806  *  NAT64 tcp BIB:
807  *   fd01:1::2 6303 10.0.0.3 62303 tcp vrf 0 dynamic 1 sessions
808  *   2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp vrf 0 static 2 sessions
809  * To show NAT64 UDP BIB entries use:
810  *  vpp# show nat64 bib udp
811  *  NAT64 udp BIB:
812  *   fd01:1::2 6304 10.0.0.3 10546 udp vrf 0 dynamic 10 sessions
813  *   2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10 static 0 sessions
814  * To show NAT64 ICMP BIB entries use:
815  *  vpp# show nat64 bib icmp
816  *  NAT64 icmp BIB:
817  *   fd01:1::2 6305 10.0.0.3 63209 icmp vrf 10 dynamic 1 sessions
818  * @cliexend
819 ?*/
820 VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
821   .path = "show nat64 bib",
822   .short_help = "show nat64 bib tcp|udp|icmp",
823   .function = nat64_show_bib_command_fn,
824 };
825
826 /*?
827  * @cliexpar
828  * @cliexstart{set nat64 timeouts}
829  * Set NAT64 session timeouts (in seconds).
830  * To set NAT64 session timeoutes use use:
831  *  vpp# set nat64 timeouts udp 200 icmp 30 tcp-trans 250 tcp-est 7450
832  * To reset NAT64 session timeoutes to default values use:
833  *  vpp# set nat64 timeouts reset
834  * @cliexend
835 ?*/
836 VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = {
837   .path = "set nat64 timeouts",
838   .short_help = "set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> "
839                 "tcp-est <sec> tcp-incoming-syn <sec> | reset",
840   .function = nat64_set_timeouts_command_fn,
841 };
842
843 /*?
844  * @cliexpar
845  * @cliexstart{show nat64 tiemouts}
846  * Show NAT64 session timeouts:
847  *  vpp# show nat64 tiemouts
848  *  NAT64 session timeouts:
849  *   UDP 300sec
850  *   ICMP 60sec
851  *   TCP transitory 240sec
852  *   TCP established 7440sec
853  *   TCP incoming SYN 6sec
854  * @cliexend
855 ?*/
856 VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = {
857   .path = "show nat64 tiemouts",
858   .short_help = "show nat64 tiemouts",
859   .function = nat64_show_timeouts_command_fn,
860 };
861
862 /*?
863  * @cliexpar
864  * @cliexstart{show nat64 session table}
865  * Show NAT64 session table.
866  * To show NAT64 TCP session table use:
867  *  vpp# show nat64 session table tcp
868  *  NAT64 tcp session table:
869  *   fd01:1::2 6303 64:ff9b::ac10:202 20 10.0.0.3 62303 172.16.2.2 20 tcp vrf 0
870  *   fd01:3::2 6303 64:ff9b::ac10:202 20 10.0.10.3 21300 172.16.2.2 20 tcp vrf 10
871  * To show NAT64 UDP session table use:
872  * #vpp show nat64 session table udp
873  * NAT64 udp session table:
874  *  fd01:1::2 6304 64:ff9b::ac10:202 20 10.0.0.3 10546 172.16.2.2 20 udp vrf 0
875  *  fd01:3::2 6304 64:ff9b::ac10:202 20 10.0.10.3 58627 172.16.2.2 20 udp vrf 10
876  *  fd01:1::2 1235 64:ff9b::a00:3 4023 10.0.0.3 24488 10.0.0.3 4023 udp vrf 0
877  *  fd01:1::3 23 64:ff9b::a00:3 24488 10.0.0.3 4023 10.0.0.3 24488 udp vrf 0
878  * To show NAT64 ICMP session table use:
879  * #vpp show nat64 session table icmp
880  * NAT64 icmp session table:
881  *  fd01:1::2 64:ff9b::ac10:202 6305 10.0.0.3 172.16.2.2 63209 icmp vrf 0
882  * @cliexend
883 ?*/
884 VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
885   .path = "show nat64 session table",
886   .short_help = "show nat64 session table tcp|udp|icmp",
887   .function = nat64_show_st_command_fn,
888 };
889
890 /*?
891  * @cliexpar
892  * @cliexstart{nat64 add prefix}
893  * Set NAT64 prefix for generating IPv6 representations of IPv4 addresses.
894  * To set NAT64 global prefix use:
895  *  vpp# nat64 add prefix 2001:db8::/32
896  * To set NAT64 prefix for specific tenant use:
897  *  vpp# nat64 add prefix 2001:db8:122:300::/56 tenant-vrf 10
898  * @cliexend
899 ?*/
900 VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
901   .path = "nat64 add prefix",
902   .short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
903                 "[del]",
904   .function = nat64_add_del_prefix_command_fn,
905 };
906
907 /*?
908  * @cliexpar
909  * @cliexstart{show nat64 prefix}
910  * Show NAT64 prefix.
911  * To show NAT64 prefix use:
912  *  vpp# show nat64 prefix
913  *  NAT64 prefix:
914  *   2001:db8::/32 tenant-vrf 0
915  *   2001:db8:122:300::/56 tenant-vrf 10
916  * @cliexend
917 ?*/
918 VLIB_CLI_COMMAND (show_nat64_prefix_command, static) = {
919   .path = "show nat64 prefix",
920   .short_help = "show nat64 prefix",
921   .function = nat64_show_prefix_command_fn,
922 };
923
924 /* *INDENT-ON* */
925
926 /*
927  * fd.io coding-style-patch-verification: ON
928  *
929  * Local Variables:
930  * eval: (c-set-style "gnu")
931  * End:
932  */