2 * decap.c : IPSec tunnel support
4 * Copyright (c) 2015 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vnet/vnet.h>
19 #include <vnet/api_errno.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/interface.h>
22 #include <vnet/fib/fib.h>
23 #include <vnet/ipip/ipip.h>
25 #include <vnet/ipsec/ipsec.h>
26 #include <vnet/ipsec/ipsec_tun.h>
29 set_interface_spd_command_fn (vlib_main_t * vm,
30 unformat_input_t * input,
31 vlib_cli_command_t * cmd)
33 unformat_input_t _line_input, *line_input = &_line_input;
34 ipsec_main_t *im = &ipsec_main;
35 u32 sw_if_index = (u32) ~ 0;
38 clib_error_t *error = NULL;
41 if (!unformat_user (input, unformat_line_input, line_input))
45 (line_input, "%U %u", unformat_vnet_sw_interface, im->vnet_main,
46 &sw_if_index, &spd_id))
48 else if (unformat (line_input, "del"))
52 error = clib_error_return (0, "parse error: '%U'",
53 format_unformat_error, line_input);
57 err = ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add);
60 case VNET_API_ERROR_SYSCALL_ERROR_1:
61 error = clib_error_return (0, "no such spd-id");
63 case VNET_API_ERROR_SYSCALL_ERROR_2:
64 error = clib_error_return (0, "spd already assigned");
69 unformat_free (line_input);
75 VLIB_CLI_COMMAND (set_interface_spd_command, static) = {
76 .path = "set interface ipsec spd",
78 "set interface ipsec spd <int> <id>",
79 .function = set_interface_spd_command_fn,
84 ipsec_sa_add_del_command_fn (vlib_main_t * vm,
85 unformat_input_t * input,
86 vlib_cli_command_t * cmd)
88 unformat_input_t _line_input, *line_input = &_line_input;
89 ip46_address_t tun_src = { }, tun_dst =
92 ipsec_crypto_alg_t crypto_alg;
93 ipsec_integ_alg_t integ_alg;
94 ipsec_protocol_t proto;
95 ipsec_sa_flags_t flags;
97 ipsec_key_t ck = { 0 };
98 ipsec_key_t ik = { 0 };
99 u32 id, spi, salt, sai;
101 u16 udp_src, udp_dst;
110 flags = IPSEC_SA_FLAG_NONE;
111 proto = IPSEC_PROTOCOL_ESP;
112 integ_alg = IPSEC_INTEG_ALG_NONE;
113 crypto_alg = IPSEC_CRYPTO_ALG_NONE;
114 udp_src = udp_dst = IPSEC_UDP_PORT_NONE;
118 if (!unformat_user (input, unformat_line_input, line_input))
121 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
123 if (unformat (line_input, "add %u", &id))
128 else if (unformat (line_input, "del %u", &id))
133 else if (unformat (line_input, "spi %u", &spi))
135 else if (unformat (line_input, "salt 0x%x", &salt))
137 else if (unformat (line_input, "esp"))
138 proto = IPSEC_PROTOCOL_ESP;
139 else if (unformat (line_input, "ah"))
140 proto = IPSEC_PROTOCOL_AH;
141 else if (unformat (line_input, "crypto-key %U",
142 unformat_ipsec_key, &ck))
144 else if (unformat (line_input, "crypto-alg %U",
145 unformat_ipsec_crypto_alg, &crypto_alg))
147 else if (unformat (line_input, "integ-key %U", unformat_ipsec_key, &ik))
149 else if (unformat (line_input, "integ-alg %U",
150 unformat_ipsec_integ_alg, &integ_alg))
152 else if (unformat (line_input, "tunnel-src %U",
153 unformat_ip46_address, &tun_src, IP46_TYPE_ANY))
155 flags |= IPSEC_SA_FLAG_IS_TUNNEL;
156 if (!ip46_address_is_ip4 (&tun_src))
157 flags |= IPSEC_SA_FLAG_IS_TUNNEL_V6;
159 else if (unformat (line_input, "tunnel-dst %U",
160 unformat_ip46_address, &tun_dst, IP46_TYPE_ANY))
162 else if (unformat (line_input, "udp-src-port %d", &i))
164 else if (unformat (line_input, "udp-dst-port %d", &i))
166 else if (unformat (line_input, "tx-table-id %d", &tx_table_id))
168 else if (unformat (line_input, "inbound"))
169 flags |= IPSEC_SA_FLAG_IS_INBOUND;
170 else if (unformat (line_input, "use-anti-replay"))
171 flags |= IPSEC_SA_FLAG_USE_ANTI_REPLAY;
172 else if (unformat (line_input, "use-esn"))
173 flags |= IPSEC_SA_FLAG_USE_ESN;
174 else if (unformat (line_input, "udp-encap"))
175 flags |= IPSEC_SA_FLAG_UDP_ENCAP;
178 error = clib_error_return (0, "parse error: '%U'",
179 format_unformat_error, line_input);
183 if ((flags & IPSEC_SA_FLAG_IS_INBOUND)
184 && !(flags & IPSEC_SA_FLAG_IS_TUNNEL))
186 error = clib_error_return (0, "inbound specified on non-tunnel SA");
192 error = clib_error_return (0, "missing id");
200 error = clib_error_return (0, "missing spi");
203 rv = ipsec_sa_add_and_lock (id, spi, proto, crypto_alg,
204 &ck, integ_alg, &ik, flags,
205 tx_table_id, clib_host_to_net_u32 (salt),
207 TUNNEL_ENCAP_DECAP_FLAG_NONE, dscp,
208 &sai, udp_src, udp_dst);
212 rv = ipsec_sa_unlock_id (id);
216 error = clib_error_return (0, "failed");
219 unformat_free (line_input);
225 VLIB_CLI_COMMAND (ipsec_sa_add_del_command, static) = {
228 "ipsec sa [add|del]",
229 .function = ipsec_sa_add_del_command_fn,
233 static clib_error_t *
234 ipsec_spd_add_del_command_fn (vlib_main_t * vm,
235 unformat_input_t * input,
236 vlib_cli_command_t * cmd)
238 unformat_input_t _line_input, *line_input = &_line_input;
241 clib_error_t *error = NULL;
243 if (!unformat_user (input, unformat_line_input, line_input))
246 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
248 if (unformat (line_input, "add"))
250 else if (unformat (line_input, "del"))
252 else if (unformat (line_input, "%u", &spd_id))
256 error = clib_error_return (0, "parse error: '%U'",
257 format_unformat_error, line_input);
264 error = clib_error_return (0, "please specify SPD ID");
268 ipsec_add_del_spd (vm, spd_id, is_add);
271 unformat_free (line_input);
277 VLIB_CLI_COMMAND (ipsec_spd_add_del_command, static) = {
280 "ipsec spd [add|del] <id>",
281 .function = ipsec_spd_add_del_command_fn,
286 static clib_error_t *
287 ipsec_policy_add_del_command_fn (vlib_main_t * vm,
288 unformat_input_t * input,
289 vlib_cli_command_t * cmd)
291 unformat_input_t _line_input, *line_input = &_line_input;
294 u32 tmp, tmp2, stat_index, local_range_set, remote_range_set;
295 clib_error_t *error = NULL;
298 clib_memset (&p, 0, sizeof (p));
299 p.lport.stop = p.rport.stop = ~0;
300 remote_range_set = local_range_set = is_outbound = 0;
302 if (!unformat_user (input, unformat_line_input, line_input))
305 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
307 if (unformat (line_input, "add"))
309 else if (unformat (line_input, "del"))
311 else if (unformat (line_input, "ip6"))
313 else if (unformat (line_input, "spd %u", &p.id))
315 else if (unformat (line_input, "inbound"))
317 else if (unformat (line_input, "outbound"))
319 else if (unformat (line_input, "priority %d", &p.priority))
321 else if (unformat (line_input, "protocol %u", &tmp))
322 p.protocol = (u8) tmp;
325 (line_input, "action %U", unformat_ipsec_policy_action,
328 if (p.policy == IPSEC_POLICY_ACTION_RESOLVE)
330 error = clib_error_return (0, "unsupported action: 'resolve'");
334 else if (unformat (line_input, "sa %u", &p.sa_id))
336 else if (unformat (line_input, "local-ip-range %U - %U",
337 unformat_ip4_address, &p.laddr.start.ip4,
338 unformat_ip4_address, &p.laddr.stop.ip4))
340 else if (unformat (line_input, "remote-ip-range %U - %U",
341 unformat_ip4_address, &p.raddr.start.ip4,
342 unformat_ip4_address, &p.raddr.stop.ip4))
343 remote_range_set = 1;
344 else if (unformat (line_input, "local-ip-range %U - %U",
345 unformat_ip6_address, &p.laddr.start.ip6,
346 unformat_ip6_address, &p.laddr.stop.ip6))
351 else if (unformat (line_input, "remote-ip-range %U - %U",
352 unformat_ip6_address, &p.raddr.start.ip6,
353 unformat_ip6_address, &p.raddr.stop.ip6))
356 remote_range_set = 1;
358 else if (unformat (line_input, "local-port-range %u - %u", &tmp, &tmp2))
364 if (unformat (line_input, "remote-port-range %u - %u", &tmp, &tmp2))
371 error = clib_error_return (0, "parse error: '%U'",
372 format_unformat_error, line_input);
377 if (!remote_range_set)
380 clib_memset (&p.raddr.stop.ip6, 0xff, 16);
382 clib_memset (&p.raddr.stop.ip4, 0xff, 4);
384 if (!local_range_set)
387 clib_memset (&p.laddr.stop.ip6, 0xff, 16);
389 clib_memset (&p.laddr.stop.ip4, 0xff, 4);
392 rv = ipsec_policy_mk_type (is_outbound, p.is_ipv6, p.policy, &p.type);
396 error = clib_error_return (0, "unsupported policy type for:",
397 " outboud:%s %s action:%U",
398 (is_outbound ? "yes" : "no"),
399 (p.is_ipv6 ? "IPv4" : "IPv6"),
400 format_ipsec_policy_action, p.policy);
404 rv = ipsec_add_del_policy (vm, &p, is_add, &stat_index);
407 vlib_cli_output (vm, "policy-index:%d", stat_index);
409 vlib_cli_output (vm, "error:%d", rv);
412 unformat_free (line_input);
418 VLIB_CLI_COMMAND (ipsec_policy_add_del_command, static) = {
419 .path = "ipsec policy",
421 "ipsec policy [add|del] spd <id> priority <n> ",
422 .function = ipsec_policy_add_del_command_fn,
427 ipsec_sa_show_all (vlib_main_t * vm, ipsec_main_t * im, u8 detail)
432 pool_foreach_index (sai, im->sad) {
433 vlib_cli_output(vm, "%U", format_ipsec_sa, sai,
434 (detail ? IPSEC_FORMAT_DETAIL : IPSEC_FORMAT_BRIEF));
440 ipsec_spd_show_all (vlib_main_t * vm, ipsec_main_t * im)
445 pool_foreach_index (spdi, im->spds) {
446 vlib_cli_output(vm, "%U", format_ipsec_spd, spdi);
452 ipsec_spd_bindings_show_all (vlib_main_t * vm, ipsec_main_t * im)
454 u32 spd_id, sw_if_index;
457 vlib_cli_output (vm, "SPD Bindings:");
460 hash_foreach(sw_if_index, spd_id, im->spd_index_by_sw_if_index, ({
461 spd = pool_elt_at_index (im->spds, spd_id);
462 vlib_cli_output (vm, " %d -> %U", spd->id,
463 format_vnet_sw_if_index_name, im->vnet_main,
470 ipsec_tun_protect_show_one (index_t itpi, void *ctx)
472 vlib_cli_output (ctx, "%U", format_ipsec_tun_protect_index, itpi);
474 return (WALK_CONTINUE);
478 ipsec_tunnel_show_all (vlib_main_t * vm)
480 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
483 static clib_error_t *
484 show_ipsec_command_fn (vlib_main_t * vm,
485 unformat_input_t * input, vlib_cli_command_t * cmd)
487 ipsec_main_t *im = &ipsec_main;
489 ipsec_sa_show_all (vm, im, 0);
490 ipsec_spd_show_all (vm, im);
491 ipsec_spd_bindings_show_all (vm, im);
492 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
494 vlib_cli_output (vm, "IPSec async mode: %s",
495 (im->async_mode ? "on" : "off"));
501 VLIB_CLI_COMMAND (show_ipsec_command, static) = {
502 .path = "show ipsec all",
503 .short_help = "show ipsec all",
504 .function = show_ipsec_command_fn,
508 static clib_error_t *
509 show_ipsec_sa_command_fn (vlib_main_t * vm,
510 unformat_input_t * input, vlib_cli_command_t * cmd)
512 ipsec_main_t *im = &ipsec_main;
516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
518 if (unformat (input, "%u", &sai))
520 if (unformat (input, "detail"))
527 ipsec_sa_show_all (vm, im, detail);
529 vlib_cli_output (vm, "%U", format_ipsec_sa, sai,
530 IPSEC_FORMAT_DETAIL | IPSEC_FORMAT_INSECURE);
535 static clib_error_t *
536 clear_ipsec_sa_command_fn (vlib_main_t * vm,
537 unformat_input_t * input, vlib_cli_command_t * cmd)
539 ipsec_main_t *im = &ipsec_main;
542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
544 if (unformat (input, "%u", &sai))
553 pool_foreach_index (sai, im->sad) {
560 if (pool_is_free_index (im->sad, sai))
561 return clib_error_return (0, "unknown SA index: %d", sai);
563 ipsec_sa_clear (sai);
570 VLIB_CLI_COMMAND (show_ipsec_sa_command, static) = {
571 .path = "show ipsec sa",
572 .short_help = "show ipsec sa [index]",
573 .function = show_ipsec_sa_command_fn,
576 VLIB_CLI_COMMAND (clear_ipsec_sa_command, static) = {
577 .path = "clear ipsec sa",
578 .short_help = "clear ipsec sa [index]",
579 .function = clear_ipsec_sa_command_fn,
583 static clib_error_t *
584 show_ipsec_spd_command_fn (vlib_main_t * vm,
585 unformat_input_t * input, vlib_cli_command_t * cmd)
587 ipsec_main_t *im = &ipsec_main;
588 u8 show_bindings = 0;
591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
593 if (unformat (input, "%u", &spdi))
595 else if (unformat (input, "bindings"))
602 ipsec_spd_bindings_show_all (vm, im);
604 vlib_cli_output (vm, "%U", format_ipsec_spd, spdi);
606 ipsec_spd_show_all (vm, im);
612 VLIB_CLI_COMMAND (show_ipsec_spd_command, static) = {
613 .path = "show ipsec spd",
614 .short_help = "show ipsec spd [index]",
615 .function = show_ipsec_spd_command_fn,
619 static clib_error_t *
620 show_ipsec_tunnel_command_fn (vlib_main_t * vm,
621 unformat_input_t * input,
622 vlib_cli_command_t * cmd)
624 ipsec_tunnel_show_all (vm);
630 VLIB_CLI_COMMAND (show_ipsec_tunnel_command, static) = {
631 .path = "show ipsec tunnel",
632 .short_help = "show ipsec tunnel",
633 .function = show_ipsec_tunnel_command_fn,
637 static clib_error_t *
638 ipsec_show_backends_command_fn (vlib_main_t * vm,
639 unformat_input_t * input,
640 vlib_cli_command_t * cmd)
642 ipsec_main_t *im = &ipsec_main;
645 (void) unformat (input, "verbose %u", &verbose);
647 vlib_cli_output (vm, "IPsec AH backends available:");
648 u8 *s = format (NULL, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
649 ipsec_ah_backend_t *ab;
651 pool_foreach (ab, im->ah_backends) {
652 s = format (s, "%=25s %=25u %=10s\n", ab->name, ab - im->ah_backends,
653 ab - im->ah_backends == im->ah_current_backend ? "yes" : "no");
656 n = vlib_get_node (vm, ab->ah4_encrypt_node_index);
657 s = format (s, " enc4 %s (next %d)\n", n->name, ab->ah4_encrypt_next_index);
658 n = vlib_get_node (vm, ab->ah4_decrypt_node_index);
659 s = format (s, " dec4 %s (next %d)\n", n->name, ab->ah4_decrypt_next_index);
660 n = vlib_get_node (vm, ab->ah6_encrypt_node_index);
661 s = format (s, " enc6 %s (next %d)\n", n->name, ab->ah6_encrypt_next_index);
662 n = vlib_get_node (vm, ab->ah6_decrypt_node_index);
663 s = format (s, " dec6 %s (next %d)\n", n->name, ab->ah6_decrypt_next_index);
667 vlib_cli_output (vm, "%v", s);
669 vlib_cli_output (vm, "IPsec ESP backends available:");
670 s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
671 ipsec_esp_backend_t *eb;
673 pool_foreach (eb, im->esp_backends) {
674 s = format (s, "%=25s %=25u %=10s\n", eb->name, eb - im->esp_backends,
675 eb - im->esp_backends == im->esp_current_backend ? "yes"
679 n = vlib_get_node (vm, eb->esp4_encrypt_node_index);
680 s = format (s, " enc4 %s (next %d)\n", n->name, eb->esp4_encrypt_next_index);
681 n = vlib_get_node (vm, eb->esp4_decrypt_node_index);
682 s = format (s, " dec4 %s (next %d)\n", n->name, eb->esp4_decrypt_next_index);
683 n = vlib_get_node (vm, eb->esp6_encrypt_node_index);
684 s = format (s, " enc6 %s (next %d)\n", n->name, eb->esp6_encrypt_next_index);
685 n = vlib_get_node (vm, eb->esp6_decrypt_node_index);
686 s = format (s, " dec6 %s (next %d)\n", n->name, eb->esp6_decrypt_next_index);
690 vlib_cli_output (vm, "%v", s);
697 VLIB_CLI_COMMAND (ipsec_show_backends_command, static) = {
698 .path = "show ipsec backends",
699 .short_help = "show ipsec backends",
700 .function = ipsec_show_backends_command_fn,
704 static clib_error_t *
705 ipsec_select_backend_command_fn (vlib_main_t * vm,
706 unformat_input_t * input,
707 vlib_cli_command_t * cmd)
709 unformat_input_t _line_input, *line_input = &_line_input;
710 ipsec_main_t *im = &ipsec_main;
714 error = ipsec_rsc_in_use (im);
719 /* Get a line of input. */
720 if (!unformat_user (input, unformat_line_input, line_input))
723 if (unformat (line_input, "ah"))
725 if (unformat (line_input, "%u", &backend_index))
727 if (ipsec_select_ah_backend (im, backend_index) < 0)
729 return clib_error_return (0, "Invalid AH backend index `%u'",
735 return clib_error_return (0, "Invalid backend index `%U'",
736 format_unformat_error, line_input);
739 else if (unformat (line_input, "esp"))
741 if (unformat (line_input, "%u", &backend_index))
743 if (ipsec_select_esp_backend (im, backend_index) < 0)
745 return clib_error_return (0, "Invalid ESP backend index `%u'",
751 return clib_error_return (0, "Invalid backend index `%U'",
752 format_unformat_error, line_input);
757 return clib_error_return (0, "Unknown input `%U'",
758 format_unformat_error, line_input);
765 VLIB_CLI_COMMAND (ipsec_select_backend_command, static) = {
766 .path = "ipsec select backend",
767 .short_help = "ipsec select backend <ah|esp> <backend index>",
768 .function = ipsec_select_backend_command_fn,
773 static clib_error_t *
774 clear_ipsec_counters_command_fn (vlib_main_t * vm,
775 unformat_input_t * input,
776 vlib_cli_command_t * cmd)
778 vlib_clear_combined_counters (&ipsec_spd_policy_counters);
779 vlib_clear_combined_counters (&ipsec_sa_counters);
785 VLIB_CLI_COMMAND (clear_ipsec_counters_command, static) = {
786 .path = "clear ipsec counters",
787 .short_help = "clear ipsec counters",
788 .function = clear_ipsec_counters_command_fn,
792 static clib_error_t *
793 ipsec_tun_protect_cmd (vlib_main_t * vm,
794 unformat_input_t * input, vlib_cli_command_t * cmd)
796 unformat_input_t _line_input, *line_input = &_line_input;
797 u32 sw_if_index, is_del, sa_in, sa_out, *sa_ins = NULL;
798 ip_address_t peer = { };
803 vnm = vnet_get_main ();
805 if (!unformat_user (input, unformat_line_input, line_input))
808 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
810 if (unformat (line_input, "del"))
812 else if (unformat (line_input, "add"))
814 else if (unformat (line_input, "sa-in %d", &sa_in))
815 vec_add1 (sa_ins, sa_in);
816 else if (unformat (line_input, "sa-out %d", &sa_out))
818 else if (unformat (line_input, "%U",
819 unformat_vnet_sw_interface, vnm, &sw_if_index))
821 else if (unformat (line_input, "%U", unformat_ip_address, &peer))
824 return (clib_error_return (0, "unknown input '%U'",
825 format_unformat_error, line_input));
829 ipsec_tun_protect_update (sw_if_index, &peer, sa_out, sa_ins);
831 ipsec_tun_protect_del (sw_if_index, &peer);
833 unformat_free (line_input);
838 * Protect tunnel with IPSEC
841 VLIB_CLI_COMMAND (ipsec_tun_protect_cmd_node, static) =
843 .path = "ipsec tunnel protect",
844 .function = ipsec_tun_protect_cmd,
845 .short_help = "ipsec tunnel protect <interface> input-sa <SA> output-sa <SA> [add|del]",
846 // this is not MP safe
851 static clib_error_t *
852 ipsec_tun_protect_show (vlib_main_t * vm,
853 unformat_input_t * input, vlib_cli_command_t * cmd)
855 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
861 * show IPSEC tunnel protection
864 VLIB_CLI_COMMAND (ipsec_tun_protect_show_node, static) =
866 .path = "show ipsec protect",
867 .function = ipsec_tun_protect_show,
868 .short_help = "show ipsec protect",
873 ipsec_tun_protect4_hash_show_one (clib_bihash_kv_8_16_t * kv, void *arg)
875 ipsec4_tunnel_kv_t *ikv = (ipsec4_tunnel_kv_t *) kv;
876 vlib_main_t *vm = arg;
878 vlib_cli_output (vm, " %U", format_ipsec4_tunnel_kv, ikv);
880 return (BIHASH_WALK_CONTINUE);
884 ipsec_tun_protect6_hash_show_one (clib_bihash_kv_24_16_t * kv, void *arg)
886 ipsec6_tunnel_kv_t *ikv = (ipsec6_tunnel_kv_t *) kv;
887 vlib_main_t *vm = arg;
889 vlib_cli_output (vm, " %U", format_ipsec6_tunnel_kv, ikv);
891 return (BIHASH_WALK_CONTINUE);
894 static clib_error_t *
895 ipsec_tun_protect_hash_show (vlib_main_t * vm,
896 unformat_input_t * input,
897 vlib_cli_command_t * cmd)
899 ipsec_main_t *im = &ipsec_main;
902 vlib_cli_output (vm, "IPv4:");
904 clib_bihash_foreach_key_value_pair_8_16
905 (&im->tun4_protect_by_key, ipsec_tun_protect4_hash_show_one, vm);
907 vlib_cli_output (vm, "IPv6:");
909 clib_bihash_foreach_key_value_pair_24_16
910 (&im->tun6_protect_by_key, ipsec_tun_protect6_hash_show_one, vm);
917 * show IPSEC tunnel protection hash tables
920 VLIB_CLI_COMMAND (ipsec_tun_protect_hash_show_node, static) =
922 .path = "show ipsec protect-hash",
923 .function = ipsec_tun_protect_hash_show,
924 .short_help = "show ipsec protect-hash",
929 ipsec_cli_init (vlib_main_t * vm)
934 VLIB_INIT_FUNCTION (ipsec_cli_init);
936 static clib_error_t *
937 set_async_mode_command_fn (vlib_main_t * vm, unformat_input_t * input,
938 vlib_cli_command_t * cmd)
940 unformat_input_t _line_input, *line_input = &_line_input;
941 int async_enable = 0;
943 if (!unformat_user (input, unformat_line_input, line_input))
946 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
948 if (unformat (line_input, "on"))
950 else if (unformat (line_input, "off"))
953 return (clib_error_return (0, "unknown input '%U'",
954 format_unformat_error, line_input));
957 vnet_crypto_request_async_mode (async_enable);
958 ipsec_set_async_mode (async_enable);
960 unformat_free (line_input);
965 VLIB_CLI_COMMAND (set_async_mode_command, static) = {
966 .path = "set ipsec async mode",
967 .short_help = "set ipsec async mode on|off",
968 .function = set_async_mode_command_fn,
973 * fd.io coding-style-patch-verification: ON
976 * eval: (c-set-style "gnu")