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 ipsec_crypto_alg_t crypto_alg;
90 ipsec_integ_alg_t integ_alg;
91 ipsec_protocol_t proto;
92 ipsec_sa_flags_t flags;
94 ipsec_key_t ck = { 0 };
95 ipsec_key_t ik = { 0 };
96 u32 id, spi, salt, sai;
106 flags = IPSEC_SA_FLAG_NONE;
107 proto = IPSEC_PROTOCOL_ESP;
108 integ_alg = IPSEC_INTEG_ALG_NONE;
109 crypto_alg = IPSEC_CRYPTO_ALG_NONE;
110 udp_src = udp_dst = IPSEC_UDP_PORT_NONE;
112 if (!unformat_user (input, unformat_line_input, line_input))
115 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
117 if (unformat (line_input, "add %u", &id))
122 else if (unformat (line_input, "del %u", &id))
127 else if (unformat (line_input, "spi %u", &spi))
129 else if (unformat (line_input, "salt 0x%x", &salt))
131 else if (unformat (line_input, "esp"))
132 proto = IPSEC_PROTOCOL_ESP;
133 else if (unformat (line_input, "ah"))
134 proto = IPSEC_PROTOCOL_AH;
135 else if (unformat (line_input, "crypto-key %U",
136 unformat_ipsec_key, &ck))
138 else if (unformat (line_input, "crypto-alg %U",
139 unformat_ipsec_crypto_alg, &crypto_alg))
141 else if (unformat (line_input, "integ-key %U", unformat_ipsec_key, &ik))
143 else if (unformat (line_input, "integ-alg %U",
144 unformat_ipsec_integ_alg, &integ_alg))
146 else if (unformat (line_input, " %U", unformat_tunnel, &tun))
148 flags |= IPSEC_SA_FLAG_IS_TUNNEL;
149 if (AF_IP6 == tunnel_get_af (&tun))
150 flags |= IPSEC_SA_FLAG_IS_TUNNEL_V6;
152 else if (unformat (line_input, "udp-src-port %d", &i))
154 else if (unformat (line_input, "udp-dst-port %d", &i))
156 else if (unformat (line_input, "inbound"))
157 flags |= IPSEC_SA_FLAG_IS_INBOUND;
158 else if (unformat (line_input, "use-anti-replay"))
159 flags |= IPSEC_SA_FLAG_USE_ANTI_REPLAY;
160 else if (unformat (line_input, "use-esn"))
161 flags |= IPSEC_SA_FLAG_USE_ESN;
162 else if (unformat (line_input, "udp-encap"))
163 flags |= IPSEC_SA_FLAG_UDP_ENCAP;
166 error = clib_error_return (0, "parse error: '%U'",
167 format_unformat_error, line_input);
171 if ((flags & IPSEC_SA_FLAG_IS_INBOUND)
172 && !(flags & IPSEC_SA_FLAG_IS_TUNNEL))
174 error = clib_error_return (0, "inbound specified on non-tunnel SA");
180 error = clib_error_return (0, "missing id");
188 error = clib_error_return (0, "missing spi");
191 rv = ipsec_sa_add_and_lock (id, spi, proto, crypto_alg, &ck, integ_alg,
192 &ik, flags, clib_host_to_net_u32 (salt),
193 udp_src, udp_dst, &tun, &sai);
197 rv = ipsec_sa_unlock_id (id);
201 error = clib_error_return (0, "failed");
204 unformat_free (line_input);
210 VLIB_CLI_COMMAND (ipsec_sa_add_del_command, static) = {
213 "ipsec sa [add|del]",
214 .function = ipsec_sa_add_del_command_fn,
218 static clib_error_t *
219 ipsec_spd_add_del_command_fn (vlib_main_t * vm,
220 unformat_input_t * input,
221 vlib_cli_command_t * cmd)
223 unformat_input_t _line_input, *line_input = &_line_input;
226 clib_error_t *error = NULL;
228 if (!unformat_user (input, unformat_line_input, line_input))
231 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
233 if (unformat (line_input, "add"))
235 else if (unformat (line_input, "del"))
237 else if (unformat (line_input, "%u", &spd_id))
241 error = clib_error_return (0, "parse error: '%U'",
242 format_unformat_error, line_input);
249 error = clib_error_return (0, "please specify SPD ID");
253 ipsec_add_del_spd (vm, spd_id, is_add);
256 unformat_free (line_input);
262 VLIB_CLI_COMMAND (ipsec_spd_add_del_command, static) = {
265 "ipsec spd [add|del] <id>",
266 .function = ipsec_spd_add_del_command_fn,
271 static clib_error_t *
272 ipsec_policy_add_del_command_fn (vlib_main_t * vm,
273 unformat_input_t * input,
274 vlib_cli_command_t * cmd)
276 unformat_input_t _line_input, *line_input = &_line_input;
279 u32 tmp, tmp2, stat_index, local_range_set, remote_range_set;
280 clib_error_t *error = NULL;
283 clib_memset (&p, 0, sizeof (p));
284 p.lport.stop = p.rport.stop = ~0;
285 remote_range_set = local_range_set = is_outbound = 0;
287 if (!unformat_user (input, unformat_line_input, line_input))
290 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
292 if (unformat (line_input, "add"))
294 else if (unformat (line_input, "del"))
296 else if (unformat (line_input, "ip6"))
298 else if (unformat (line_input, "spd %u", &p.id))
300 else if (unformat (line_input, "inbound"))
302 else if (unformat (line_input, "outbound"))
304 else if (unformat (line_input, "priority %d", &p.priority))
306 else if (unformat (line_input, "protocol %u", &tmp))
307 p.protocol = (u8) tmp;
310 (line_input, "action %U", unformat_ipsec_policy_action,
313 if (p.policy == IPSEC_POLICY_ACTION_RESOLVE)
315 error = clib_error_return (0, "unsupported action: 'resolve'");
319 else if (unformat (line_input, "sa %u", &p.sa_id))
321 else if (unformat (line_input, "local-ip-range %U - %U",
322 unformat_ip4_address, &p.laddr.start.ip4,
323 unformat_ip4_address, &p.laddr.stop.ip4))
325 else if (unformat (line_input, "remote-ip-range %U - %U",
326 unformat_ip4_address, &p.raddr.start.ip4,
327 unformat_ip4_address, &p.raddr.stop.ip4))
328 remote_range_set = 1;
329 else if (unformat (line_input, "local-ip-range %U - %U",
330 unformat_ip6_address, &p.laddr.start.ip6,
331 unformat_ip6_address, &p.laddr.stop.ip6))
336 else if (unformat (line_input, "remote-ip-range %U - %U",
337 unformat_ip6_address, &p.raddr.start.ip6,
338 unformat_ip6_address, &p.raddr.stop.ip6))
341 remote_range_set = 1;
343 else if (unformat (line_input, "local-port-range %u - %u", &tmp, &tmp2))
349 if (unformat (line_input, "remote-port-range %u - %u", &tmp, &tmp2))
356 error = clib_error_return (0, "parse error: '%U'",
357 format_unformat_error, line_input);
362 if (!remote_range_set)
365 clib_memset (&p.raddr.stop.ip6, 0xff, 16);
367 clib_memset (&p.raddr.stop.ip4, 0xff, 4);
369 if (!local_range_set)
372 clib_memset (&p.laddr.stop.ip6, 0xff, 16);
374 clib_memset (&p.laddr.stop.ip4, 0xff, 4);
377 rv = ipsec_policy_mk_type (is_outbound, p.is_ipv6, p.policy, &p.type);
381 error = clib_error_return (0, "unsupported policy type for:",
382 " outboud:%s %s action:%U",
383 (is_outbound ? "yes" : "no"),
384 (p.is_ipv6 ? "IPv4" : "IPv6"),
385 format_ipsec_policy_action, p.policy);
389 rv = ipsec_add_del_policy (vm, &p, is_add, &stat_index);
392 vlib_cli_output (vm, "policy-index:%d", stat_index);
394 vlib_cli_output (vm, "error:%d", rv);
397 unformat_free (line_input);
403 VLIB_CLI_COMMAND (ipsec_policy_add_del_command, static) = {
404 .path = "ipsec policy",
406 "ipsec policy [add|del] spd <id> priority <n> ",
407 .function = ipsec_policy_add_del_command_fn,
412 ipsec_sa_show_all (vlib_main_t * vm, ipsec_main_t * im, u8 detail)
417 pool_foreach_index (sai, im->sad) {
418 vlib_cli_output(vm, "%U", format_ipsec_sa, sai,
419 (detail ? IPSEC_FORMAT_DETAIL : IPSEC_FORMAT_BRIEF));
425 ipsec_spd_show_all (vlib_main_t * vm, ipsec_main_t * im)
430 pool_foreach_index (spdi, im->spds) {
431 vlib_cli_output(vm, "%U", format_ipsec_spd, spdi);
437 ipsec_spd_bindings_show_all (vlib_main_t * vm, ipsec_main_t * im)
439 u32 spd_id, sw_if_index;
442 vlib_cli_output (vm, "SPD Bindings:");
445 hash_foreach(sw_if_index, spd_id, im->spd_index_by_sw_if_index, ({
446 spd = pool_elt_at_index (im->spds, spd_id);
447 vlib_cli_output (vm, " %d -> %U", spd->id,
448 format_vnet_sw_if_index_name, im->vnet_main,
455 ipsec_tun_protect_show_one (index_t itpi, void *ctx)
457 vlib_cli_output (ctx, "%U", format_ipsec_tun_protect_index, itpi);
459 return (WALK_CONTINUE);
463 ipsec_tunnel_show_all (vlib_main_t * vm)
465 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
468 static clib_error_t *
469 show_ipsec_command_fn (vlib_main_t * vm,
470 unformat_input_t * input, vlib_cli_command_t * cmd)
472 ipsec_main_t *im = &ipsec_main;
474 ipsec_sa_show_all (vm, im, 0);
475 ipsec_spd_show_all (vm, im);
476 ipsec_spd_bindings_show_all (vm, im);
477 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
479 vlib_cli_output (vm, "IPSec async mode: %s",
480 (im->async_mode ? "on" : "off"));
486 VLIB_CLI_COMMAND (show_ipsec_command, static) = {
487 .path = "show ipsec all",
488 .short_help = "show ipsec all",
489 .function = show_ipsec_command_fn,
493 static clib_error_t *
494 show_ipsec_sa_command_fn (vlib_main_t * vm,
495 unformat_input_t * input, vlib_cli_command_t * cmd)
497 ipsec_main_t *im = &ipsec_main;
501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
503 if (unformat (input, "%u", &sai))
505 if (unformat (input, "detail"))
512 ipsec_sa_show_all (vm, im, detail);
514 vlib_cli_output (vm, "%U", format_ipsec_sa, sai,
515 IPSEC_FORMAT_DETAIL | IPSEC_FORMAT_INSECURE);
520 static clib_error_t *
521 clear_ipsec_sa_command_fn (vlib_main_t * vm,
522 unformat_input_t * input, vlib_cli_command_t * cmd)
524 ipsec_main_t *im = &ipsec_main;
527 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
529 if (unformat (input, "%u", &sai))
538 pool_foreach_index (sai, im->sad) {
545 if (pool_is_free_index (im->sad, sai))
546 return clib_error_return (0, "unknown SA index: %d", sai);
548 ipsec_sa_clear (sai);
555 VLIB_CLI_COMMAND (show_ipsec_sa_command, static) = {
556 .path = "show ipsec sa",
557 .short_help = "show ipsec sa [index]",
558 .function = show_ipsec_sa_command_fn,
561 VLIB_CLI_COMMAND (clear_ipsec_sa_command, static) = {
562 .path = "clear ipsec sa",
563 .short_help = "clear ipsec sa [index]",
564 .function = clear_ipsec_sa_command_fn,
568 static clib_error_t *
569 show_ipsec_spd_command_fn (vlib_main_t * vm,
570 unformat_input_t * input, vlib_cli_command_t * cmd)
572 ipsec_main_t *im = &ipsec_main;
573 u8 show_bindings = 0;
576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
578 if (unformat (input, "%u", &spdi))
580 else if (unformat (input, "bindings"))
587 ipsec_spd_bindings_show_all (vm, im);
589 vlib_cli_output (vm, "%U", format_ipsec_spd, spdi);
591 ipsec_spd_show_all (vm, im);
597 VLIB_CLI_COMMAND (show_ipsec_spd_command, static) = {
598 .path = "show ipsec spd",
599 .short_help = "show ipsec spd [index]",
600 .function = show_ipsec_spd_command_fn,
604 static clib_error_t *
605 show_ipsec_tunnel_command_fn (vlib_main_t * vm,
606 unformat_input_t * input,
607 vlib_cli_command_t * cmd)
609 ipsec_tunnel_show_all (vm);
615 VLIB_CLI_COMMAND (show_ipsec_tunnel_command, static) = {
616 .path = "show ipsec tunnel",
617 .short_help = "show ipsec tunnel",
618 .function = show_ipsec_tunnel_command_fn,
622 static clib_error_t *
623 ipsec_show_backends_command_fn (vlib_main_t * vm,
624 unformat_input_t * input,
625 vlib_cli_command_t * cmd)
627 ipsec_main_t *im = &ipsec_main;
630 (void) unformat (input, "verbose %u", &verbose);
632 vlib_cli_output (vm, "IPsec AH backends available:");
633 u8 *s = format (NULL, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
634 ipsec_ah_backend_t *ab;
636 pool_foreach (ab, im->ah_backends) {
637 s = format (s, "%=25s %=25u %=10s\n", ab->name, ab - im->ah_backends,
638 ab - im->ah_backends == im->ah_current_backend ? "yes" : "no");
641 n = vlib_get_node (vm, ab->ah4_encrypt_node_index);
642 s = format (s, " enc4 %s (next %d)\n", n->name, ab->ah4_encrypt_next_index);
643 n = vlib_get_node (vm, ab->ah4_decrypt_node_index);
644 s = format (s, " dec4 %s (next %d)\n", n->name, ab->ah4_decrypt_next_index);
645 n = vlib_get_node (vm, ab->ah6_encrypt_node_index);
646 s = format (s, " enc6 %s (next %d)\n", n->name, ab->ah6_encrypt_next_index);
647 n = vlib_get_node (vm, ab->ah6_decrypt_node_index);
648 s = format (s, " dec6 %s (next %d)\n", n->name, ab->ah6_decrypt_next_index);
652 vlib_cli_output (vm, "%v", s);
654 vlib_cli_output (vm, "IPsec ESP backends available:");
655 s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
656 ipsec_esp_backend_t *eb;
658 pool_foreach (eb, im->esp_backends) {
659 s = format (s, "%=25s %=25u %=10s\n", eb->name, eb - im->esp_backends,
660 eb - im->esp_backends == im->esp_current_backend ? "yes"
664 n = vlib_get_node (vm, eb->esp4_encrypt_node_index);
665 s = format (s, " enc4 %s (next %d)\n", n->name, eb->esp4_encrypt_next_index);
666 n = vlib_get_node (vm, eb->esp4_decrypt_node_index);
667 s = format (s, " dec4 %s (next %d)\n", n->name, eb->esp4_decrypt_next_index);
668 n = vlib_get_node (vm, eb->esp6_encrypt_node_index);
669 s = format (s, " enc6 %s (next %d)\n", n->name, eb->esp6_encrypt_next_index);
670 n = vlib_get_node (vm, eb->esp6_decrypt_node_index);
671 s = format (s, " dec6 %s (next %d)\n", n->name, eb->esp6_decrypt_next_index);
675 vlib_cli_output (vm, "%v", s);
682 VLIB_CLI_COMMAND (ipsec_show_backends_command, static) = {
683 .path = "show ipsec backends",
684 .short_help = "show ipsec backends",
685 .function = ipsec_show_backends_command_fn,
689 static clib_error_t *
690 ipsec_select_backend_command_fn (vlib_main_t * vm,
691 unformat_input_t * input,
692 vlib_cli_command_t * cmd)
694 unformat_input_t _line_input, *line_input = &_line_input;
695 ipsec_main_t *im = &ipsec_main;
699 error = ipsec_rsc_in_use (im);
704 /* Get a line of input. */
705 if (!unformat_user (input, unformat_line_input, line_input))
708 if (unformat (line_input, "ah"))
710 if (unformat (line_input, "%u", &backend_index))
712 if (ipsec_select_ah_backend (im, backend_index) < 0)
714 return clib_error_return (0, "Invalid AH backend index `%u'",
720 return clib_error_return (0, "Invalid backend index `%U'",
721 format_unformat_error, line_input);
724 else if (unformat (line_input, "esp"))
726 if (unformat (line_input, "%u", &backend_index))
728 if (ipsec_select_esp_backend (im, backend_index) < 0)
730 return clib_error_return (0, "Invalid ESP backend index `%u'",
736 return clib_error_return (0, "Invalid backend index `%U'",
737 format_unformat_error, line_input);
742 return clib_error_return (0, "Unknown input `%U'",
743 format_unformat_error, line_input);
750 VLIB_CLI_COMMAND (ipsec_select_backend_command, static) = {
751 .path = "ipsec select backend",
752 .short_help = "ipsec select backend <ah|esp> <backend index>",
753 .function = ipsec_select_backend_command_fn,
758 static clib_error_t *
759 clear_ipsec_counters_command_fn (vlib_main_t * vm,
760 unformat_input_t * input,
761 vlib_cli_command_t * cmd)
763 vlib_clear_combined_counters (&ipsec_spd_policy_counters);
764 vlib_clear_combined_counters (&ipsec_sa_counters);
770 VLIB_CLI_COMMAND (clear_ipsec_counters_command, static) = {
771 .path = "clear ipsec counters",
772 .short_help = "clear ipsec counters",
773 .function = clear_ipsec_counters_command_fn,
777 static clib_error_t *
778 ipsec_tun_protect_cmd (vlib_main_t * vm,
779 unformat_input_t * input, vlib_cli_command_t * cmd)
781 unformat_input_t _line_input, *line_input = &_line_input;
782 u32 sw_if_index, is_del, sa_in, sa_out, *sa_ins = NULL;
783 ip_address_t peer = { };
788 vnm = vnet_get_main ();
790 if (!unformat_user (input, unformat_line_input, line_input))
793 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
795 if (unformat (line_input, "del"))
797 else if (unformat (line_input, "add"))
799 else if (unformat (line_input, "sa-in %d", &sa_in))
800 vec_add1 (sa_ins, sa_in);
801 else if (unformat (line_input, "sa-out %d", &sa_out))
803 else if (unformat (line_input, "%U",
804 unformat_vnet_sw_interface, vnm, &sw_if_index))
806 else if (unformat (line_input, "%U", unformat_ip_address, &peer))
809 return (clib_error_return (0, "unknown input '%U'",
810 format_unformat_error, line_input));
814 ipsec_tun_protect_update (sw_if_index, &peer, sa_out, sa_ins);
816 ipsec_tun_protect_del (sw_if_index, &peer);
818 unformat_free (line_input);
823 * Protect tunnel with IPSEC
826 VLIB_CLI_COMMAND (ipsec_tun_protect_cmd_node, static) =
828 .path = "ipsec tunnel protect",
829 .function = ipsec_tun_protect_cmd,
830 .short_help = "ipsec tunnel protect <interface> input-sa <SA> output-sa <SA> [add|del]",
831 // this is not MP safe
836 static clib_error_t *
837 ipsec_tun_protect_show (vlib_main_t * vm,
838 unformat_input_t * input, vlib_cli_command_t * cmd)
840 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
846 * show IPSEC tunnel protection
849 VLIB_CLI_COMMAND (ipsec_tun_protect_show_node, static) =
851 .path = "show ipsec protect",
852 .function = ipsec_tun_protect_show,
853 .short_help = "show ipsec protect",
858 ipsec_tun_protect4_hash_show_one (clib_bihash_kv_8_16_t * kv, void *arg)
860 ipsec4_tunnel_kv_t *ikv = (ipsec4_tunnel_kv_t *) kv;
861 vlib_main_t *vm = arg;
863 vlib_cli_output (vm, " %U", format_ipsec4_tunnel_kv, ikv);
865 return (BIHASH_WALK_CONTINUE);
869 ipsec_tun_protect6_hash_show_one (clib_bihash_kv_24_16_t * kv, void *arg)
871 ipsec6_tunnel_kv_t *ikv = (ipsec6_tunnel_kv_t *) kv;
872 vlib_main_t *vm = arg;
874 vlib_cli_output (vm, " %U", format_ipsec6_tunnel_kv, ikv);
876 return (BIHASH_WALK_CONTINUE);
879 static clib_error_t *
880 ipsec_tun_protect_hash_show (vlib_main_t * vm,
881 unformat_input_t * input,
882 vlib_cli_command_t * cmd)
884 ipsec_main_t *im = &ipsec_main;
887 vlib_cli_output (vm, "IPv4:");
889 clib_bihash_foreach_key_value_pair_8_16
890 (&im->tun4_protect_by_key, ipsec_tun_protect4_hash_show_one, vm);
892 vlib_cli_output (vm, "IPv6:");
894 clib_bihash_foreach_key_value_pair_24_16
895 (&im->tun6_protect_by_key, ipsec_tun_protect6_hash_show_one, vm);
902 * show IPSEC tunnel protection hash tables
905 VLIB_CLI_COMMAND (ipsec_tun_protect_hash_show_node, static) =
907 .path = "show ipsec protect-hash",
908 .function = ipsec_tun_protect_hash_show,
909 .short_help = "show ipsec protect-hash",
914 ipsec_cli_init (vlib_main_t * vm)
919 VLIB_INIT_FUNCTION (ipsec_cli_init);
921 static clib_error_t *
922 set_async_mode_command_fn (vlib_main_t * vm, unformat_input_t * input,
923 vlib_cli_command_t * cmd)
925 unformat_input_t _line_input, *line_input = &_line_input;
926 int async_enable = 0;
928 if (!unformat_user (input, unformat_line_input, line_input))
931 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
933 if (unformat (line_input, "on"))
935 else if (unformat (line_input, "off"))
938 return (clib_error_return (0, "unknown input '%U'",
939 format_unformat_error, line_input));
942 vnet_crypto_request_async_mode (async_enable);
943 ipsec_set_async_mode (async_enable);
945 unformat_free (line_input);
950 VLIB_CLI_COMMAND (set_async_mode_command, static) = {
951 .path = "set ipsec async mode",
952 .short_help = "set ipsec async mode on|off",
953 .function = set_async_mode_command_fn,
958 * fd.io coding-style-patch-verification: ON
961 * eval: (c-set-style "gnu")