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;
100 u16 udp_src, udp_dst;
109 flags = IPSEC_SA_FLAG_NONE;
110 proto = IPSEC_PROTOCOL_ESP;
111 integ_alg = IPSEC_INTEG_ALG_NONE;
112 crypto_alg = IPSEC_CRYPTO_ALG_NONE;
113 udp_src = udp_dst = IPSEC_UDP_PORT_NONE;
117 if (!unformat_user (input, unformat_line_input, line_input))
120 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
122 if (unformat (line_input, "add %u", &id))
127 else if (unformat (line_input, "del %u", &id))
132 else if (unformat (line_input, "spi %u", &spi))
134 else if (unformat (line_input, "salt 0x%x", &salt))
136 else if (unformat (line_input, "esp"))
137 proto = IPSEC_PROTOCOL_ESP;
138 else if (unformat (line_input, "ah"))
139 proto = IPSEC_PROTOCOL_AH;
140 else if (unformat (line_input, "crypto-key %U",
141 unformat_ipsec_key, &ck))
143 else if (unformat (line_input, "crypto-alg %U",
144 unformat_ipsec_crypto_alg, &crypto_alg))
146 else if (unformat (line_input, "integ-key %U", unformat_ipsec_key, &ik))
148 else if (unformat (line_input, "integ-alg %U",
149 unformat_ipsec_integ_alg, &integ_alg))
151 else if (unformat (line_input, "tunnel-src %U",
152 unformat_ip46_address, &tun_src, IP46_TYPE_ANY))
154 flags |= IPSEC_SA_FLAG_IS_TUNNEL;
155 if (!ip46_address_is_ip4 (&tun_src))
156 flags |= IPSEC_SA_FLAG_IS_TUNNEL_V6;
158 else if (unformat (line_input, "tunnel-dst %U",
159 unformat_ip46_address, &tun_dst, IP46_TYPE_ANY))
161 else if (unformat (line_input, "tx-table-id %d", &tx_table_id))
163 else if (unformat (line_input, "inbound"))
164 flags |= IPSEC_SA_FLAG_IS_INBOUND;
165 else if (unformat (line_input, "use-anti-replay"))
166 flags |= IPSEC_SA_FLAG_USE_ANTI_REPLAY;
167 else if (unformat (line_input, "use-esn"))
168 flags |= IPSEC_SA_FLAG_USE_ESN;
169 else if (unformat (line_input, "udp-encap"))
170 flags |= IPSEC_SA_FLAG_UDP_ENCAP;
173 error = clib_error_return (0, "parse error: '%U'",
174 format_unformat_error, line_input);
178 if ((flags & IPSEC_SA_FLAG_IS_INBOUND)
179 && !(flags & IPSEC_SA_FLAG_IS_TUNNEL))
181 error = clib_error_return (0, "inbound specified on non-tunnel SA");
187 error = clib_error_return (0, "missing id");
195 error = clib_error_return (0, "missing spi");
198 rv = ipsec_sa_add_and_lock (id, spi, proto, crypto_alg,
199 &ck, integ_alg, &ik, flags,
200 tx_table_id, clib_host_to_net_u32 (salt),
202 TUNNEL_ENCAP_DECAP_FLAG_NONE, dscp,
203 &sai, udp_src, udp_dst);
207 rv = ipsec_sa_unlock_id (id);
211 error = clib_error_return (0, "failed");
214 unformat_free (line_input);
220 VLIB_CLI_COMMAND (ipsec_sa_add_del_command, static) = {
223 "ipsec sa [add|del]",
224 .function = ipsec_sa_add_del_command_fn,
228 static clib_error_t *
229 ipsec_spd_add_del_command_fn (vlib_main_t * vm,
230 unformat_input_t * input,
231 vlib_cli_command_t * cmd)
233 unformat_input_t _line_input, *line_input = &_line_input;
236 clib_error_t *error = NULL;
238 if (!unformat_user (input, unformat_line_input, line_input))
241 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
243 if (unformat (line_input, "add"))
245 else if (unformat (line_input, "del"))
247 else if (unformat (line_input, "%u", &spd_id))
251 error = clib_error_return (0, "parse error: '%U'",
252 format_unformat_error, line_input);
259 error = clib_error_return (0, "please specify SPD ID");
263 ipsec_add_del_spd (vm, spd_id, is_add);
266 unformat_free (line_input);
272 VLIB_CLI_COMMAND (ipsec_spd_add_del_command, static) = {
275 "ipsec spd [add|del] <id>",
276 .function = ipsec_spd_add_del_command_fn,
281 static clib_error_t *
282 ipsec_policy_add_del_command_fn (vlib_main_t * vm,
283 unformat_input_t * input,
284 vlib_cli_command_t * cmd)
286 unformat_input_t _line_input, *line_input = &_line_input;
289 u32 tmp, tmp2, stat_index, local_range_set, remote_range_set;
290 clib_error_t *error = NULL;
293 clib_memset (&p, 0, sizeof (p));
294 p.lport.stop = p.rport.stop = ~0;
295 remote_range_set = local_range_set = is_outbound = 0;
297 if (!unformat_user (input, unformat_line_input, line_input))
300 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
302 if (unformat (line_input, "add"))
304 else if (unformat (line_input, "del"))
306 else if (unformat (line_input, "ip6"))
308 else if (unformat (line_input, "spd %u", &p.id))
310 else if (unformat (line_input, "inbound"))
312 else if (unformat (line_input, "outbound"))
314 else if (unformat (line_input, "priority %d", &p.priority))
316 else if (unformat (line_input, "protocol %u", &tmp))
317 p.protocol = (u8) tmp;
320 (line_input, "action %U", unformat_ipsec_policy_action,
323 if (p.policy == IPSEC_POLICY_ACTION_RESOLVE)
325 error = clib_error_return (0, "unsupported action: 'resolve'");
329 else if (unformat (line_input, "sa %u", &p.sa_id))
331 else if (unformat (line_input, "local-ip-range %U - %U",
332 unformat_ip4_address, &p.laddr.start.ip4,
333 unformat_ip4_address, &p.laddr.stop.ip4))
335 else if (unformat (line_input, "remote-ip-range %U - %U",
336 unformat_ip4_address, &p.raddr.start.ip4,
337 unformat_ip4_address, &p.raddr.stop.ip4))
338 remote_range_set = 1;
339 else if (unformat (line_input, "local-ip-range %U - %U",
340 unformat_ip6_address, &p.laddr.start.ip6,
341 unformat_ip6_address, &p.laddr.stop.ip6))
346 else if (unformat (line_input, "remote-ip-range %U - %U",
347 unformat_ip6_address, &p.raddr.start.ip6,
348 unformat_ip6_address, &p.raddr.stop.ip6))
351 remote_range_set = 1;
353 else if (unformat (line_input, "local-port-range %u - %u", &tmp, &tmp2))
359 if (unformat (line_input, "remote-port-range %u - %u", &tmp, &tmp2))
366 error = clib_error_return (0, "parse error: '%U'",
367 format_unformat_error, line_input);
372 if (!remote_range_set)
375 clib_memset (&p.raddr.stop.ip6, 0xff, 16);
377 clib_memset (&p.raddr.stop.ip4, 0xff, 4);
379 if (!local_range_set)
382 clib_memset (&p.laddr.stop.ip6, 0xff, 16);
384 clib_memset (&p.laddr.stop.ip4, 0xff, 4);
387 rv = ipsec_policy_mk_type (is_outbound, p.is_ipv6, p.policy, &p.type);
391 error = clib_error_return (0, "unsupported policy type for:",
392 " outboud:%s %s action:%U",
393 (is_outbound ? "yes" : "no"),
394 (p.is_ipv6 ? "IPv4" : "IPv6"),
395 format_ipsec_policy_action, p.policy);
399 rv = ipsec_add_del_policy (vm, &p, is_add, &stat_index);
402 vlib_cli_output (vm, "policy-index:%d", stat_index);
404 vlib_cli_output (vm, "error:%d", rv);
407 unformat_free (line_input);
413 VLIB_CLI_COMMAND (ipsec_policy_add_del_command, static) = {
414 .path = "ipsec policy",
416 "ipsec policy [add|del] spd <id> priority <n> ",
417 .function = ipsec_policy_add_del_command_fn,
422 ipsec_sa_show_all (vlib_main_t * vm, ipsec_main_t * im, u8 detail)
427 pool_foreach_index (sai, im->sad) {
428 vlib_cli_output(vm, "%U", format_ipsec_sa, sai,
429 (detail ? IPSEC_FORMAT_DETAIL : IPSEC_FORMAT_BRIEF));
435 ipsec_spd_show_all (vlib_main_t * vm, ipsec_main_t * im)
440 pool_foreach_index (spdi, im->spds) {
441 vlib_cli_output(vm, "%U", format_ipsec_spd, spdi);
447 ipsec_spd_bindings_show_all (vlib_main_t * vm, ipsec_main_t * im)
449 u32 spd_id, sw_if_index;
452 vlib_cli_output (vm, "SPD Bindings:");
455 hash_foreach(sw_if_index, spd_id, im->spd_index_by_sw_if_index, ({
456 spd = pool_elt_at_index (im->spds, spd_id);
457 vlib_cli_output (vm, " %d -> %U", spd->id,
458 format_vnet_sw_if_index_name, im->vnet_main,
465 ipsec_tun_protect_show_one (index_t itpi, void *ctx)
467 vlib_cli_output (ctx, "%U", format_ipsec_tun_protect_index, itpi);
469 return (WALK_CONTINUE);
473 ipsec_tunnel_show_all (vlib_main_t * vm)
475 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
478 static clib_error_t *
479 show_ipsec_command_fn (vlib_main_t * vm,
480 unformat_input_t * input, vlib_cli_command_t * cmd)
482 ipsec_main_t *im = &ipsec_main;
484 ipsec_sa_show_all (vm, im, 0);
485 ipsec_spd_show_all (vm, im);
486 ipsec_spd_bindings_show_all (vm, im);
487 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
489 vlib_cli_output (vm, "IPSec async mode: %s",
490 (im->async_mode ? "on" : "off"));
496 VLIB_CLI_COMMAND (show_ipsec_command, static) = {
497 .path = "show ipsec all",
498 .short_help = "show ipsec all",
499 .function = show_ipsec_command_fn,
503 static clib_error_t *
504 show_ipsec_sa_command_fn (vlib_main_t * vm,
505 unformat_input_t * input, vlib_cli_command_t * cmd)
507 ipsec_main_t *im = &ipsec_main;
511 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
513 if (unformat (input, "%u", &sai))
515 if (unformat (input, "detail"))
522 ipsec_sa_show_all (vm, im, detail);
524 vlib_cli_output (vm, "%U", format_ipsec_sa, sai,
525 IPSEC_FORMAT_DETAIL | IPSEC_FORMAT_INSECURE);
530 static clib_error_t *
531 clear_ipsec_sa_command_fn (vlib_main_t * vm,
532 unformat_input_t * input, vlib_cli_command_t * cmd)
534 ipsec_main_t *im = &ipsec_main;
537 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
539 if (unformat (input, "%u", &sai))
548 pool_foreach_index (sai, im->sad) {
555 if (pool_is_free_index (im->sad, sai))
556 return clib_error_return (0, "unknown SA index: %d", sai);
558 ipsec_sa_clear (sai);
565 VLIB_CLI_COMMAND (show_ipsec_sa_command, static) = {
566 .path = "show ipsec sa",
567 .short_help = "show ipsec sa [index]",
568 .function = show_ipsec_sa_command_fn,
571 VLIB_CLI_COMMAND (clear_ipsec_sa_command, static) = {
572 .path = "clear ipsec sa",
573 .short_help = "clear ipsec sa [index]",
574 .function = clear_ipsec_sa_command_fn,
578 static clib_error_t *
579 show_ipsec_spd_command_fn (vlib_main_t * vm,
580 unformat_input_t * input, vlib_cli_command_t * cmd)
582 ipsec_main_t *im = &ipsec_main;
583 u8 show_bindings = 0;
586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
588 if (unformat (input, "%u", &spdi))
590 else if (unformat (input, "bindings"))
597 ipsec_spd_bindings_show_all (vm, im);
599 vlib_cli_output (vm, "%U", format_ipsec_spd, spdi);
601 ipsec_spd_show_all (vm, im);
607 VLIB_CLI_COMMAND (show_ipsec_spd_command, static) = {
608 .path = "show ipsec spd",
609 .short_help = "show ipsec spd [index]",
610 .function = show_ipsec_spd_command_fn,
614 static clib_error_t *
615 show_ipsec_tunnel_command_fn (vlib_main_t * vm,
616 unformat_input_t * input,
617 vlib_cli_command_t * cmd)
619 ipsec_tunnel_show_all (vm);
625 VLIB_CLI_COMMAND (show_ipsec_tunnel_command, static) = {
626 .path = "show ipsec tunnel",
627 .short_help = "show ipsec tunnel",
628 .function = show_ipsec_tunnel_command_fn,
632 static clib_error_t *
633 ipsec_show_backends_command_fn (vlib_main_t * vm,
634 unformat_input_t * input,
635 vlib_cli_command_t * cmd)
637 ipsec_main_t *im = &ipsec_main;
640 (void) unformat (input, "verbose %u", &verbose);
642 vlib_cli_output (vm, "IPsec AH backends available:");
643 u8 *s = format (NULL, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
644 ipsec_ah_backend_t *ab;
646 pool_foreach (ab, im->ah_backends) {
647 s = format (s, "%=25s %=25u %=10s\n", ab->name, ab - im->ah_backends,
648 ab - im->ah_backends == im->ah_current_backend ? "yes" : "no");
651 n = vlib_get_node (vm, ab->ah4_encrypt_node_index);
652 s = format (s, " enc4 %s (next %d)\n", n->name, ab->ah4_encrypt_next_index);
653 n = vlib_get_node (vm, ab->ah4_decrypt_node_index);
654 s = format (s, " dec4 %s (next %d)\n", n->name, ab->ah4_decrypt_next_index);
655 n = vlib_get_node (vm, ab->ah6_encrypt_node_index);
656 s = format (s, " enc6 %s (next %d)\n", n->name, ab->ah6_encrypt_next_index);
657 n = vlib_get_node (vm, ab->ah6_decrypt_node_index);
658 s = format (s, " dec6 %s (next %d)\n", n->name, ab->ah6_decrypt_next_index);
662 vlib_cli_output (vm, "%v", s);
664 vlib_cli_output (vm, "IPsec ESP backends available:");
665 s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
666 ipsec_esp_backend_t *eb;
668 pool_foreach (eb, im->esp_backends) {
669 s = format (s, "%=25s %=25u %=10s\n", eb->name, eb - im->esp_backends,
670 eb - im->esp_backends == im->esp_current_backend ? "yes"
674 n = vlib_get_node (vm, eb->esp4_encrypt_node_index);
675 s = format (s, " enc4 %s (next %d)\n", n->name, eb->esp4_encrypt_next_index);
676 n = vlib_get_node (vm, eb->esp4_decrypt_node_index);
677 s = format (s, " dec4 %s (next %d)\n", n->name, eb->esp4_decrypt_next_index);
678 n = vlib_get_node (vm, eb->esp6_encrypt_node_index);
679 s = format (s, " enc6 %s (next %d)\n", n->name, eb->esp6_encrypt_next_index);
680 n = vlib_get_node (vm, eb->esp6_decrypt_node_index);
681 s = format (s, " dec6 %s (next %d)\n", n->name, eb->esp6_decrypt_next_index);
685 vlib_cli_output (vm, "%v", s);
692 VLIB_CLI_COMMAND (ipsec_show_backends_command, static) = {
693 .path = "show ipsec backends",
694 .short_help = "show ipsec backends",
695 .function = ipsec_show_backends_command_fn,
699 static clib_error_t *
700 ipsec_select_backend_command_fn (vlib_main_t * vm,
701 unformat_input_t * input,
702 vlib_cli_command_t * cmd)
704 unformat_input_t _line_input, *line_input = &_line_input;
705 ipsec_main_t *im = &ipsec_main;
709 error = ipsec_rsc_in_use (im);
714 /* Get a line of input. */
715 if (!unformat_user (input, unformat_line_input, line_input))
718 if (unformat (line_input, "ah"))
720 if (unformat (line_input, "%u", &backend_index))
722 if (ipsec_select_ah_backend (im, backend_index) < 0)
724 return clib_error_return (0, "Invalid AH backend index `%u'",
730 return clib_error_return (0, "Invalid backend index `%U'",
731 format_unformat_error, line_input);
734 else if (unformat (line_input, "esp"))
736 if (unformat (line_input, "%u", &backend_index))
738 if (ipsec_select_esp_backend (im, backend_index) < 0)
740 return clib_error_return (0, "Invalid ESP backend index `%u'",
746 return clib_error_return (0, "Invalid backend index `%U'",
747 format_unformat_error, line_input);
752 return clib_error_return (0, "Unknown input `%U'",
753 format_unformat_error, line_input);
760 VLIB_CLI_COMMAND (ipsec_select_backend_command, static) = {
761 .path = "ipsec select backend",
762 .short_help = "ipsec select backend <ah|esp> <backend index>",
763 .function = ipsec_select_backend_command_fn,
768 static clib_error_t *
769 clear_ipsec_counters_command_fn (vlib_main_t * vm,
770 unformat_input_t * input,
771 vlib_cli_command_t * cmd)
773 vlib_clear_combined_counters (&ipsec_spd_policy_counters);
774 vlib_clear_combined_counters (&ipsec_sa_counters);
780 VLIB_CLI_COMMAND (clear_ipsec_counters_command, static) = {
781 .path = "clear ipsec counters",
782 .short_help = "clear ipsec counters",
783 .function = clear_ipsec_counters_command_fn,
787 static clib_error_t *
788 ipsec_tun_protect_cmd (vlib_main_t * vm,
789 unformat_input_t * input, vlib_cli_command_t * cmd)
791 unformat_input_t _line_input, *line_input = &_line_input;
792 u32 sw_if_index, is_del, sa_in, sa_out, *sa_ins = NULL;
793 ip_address_t peer = { };
798 vnm = vnet_get_main ();
800 if (!unformat_user (input, unformat_line_input, line_input))
803 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
805 if (unformat (line_input, "del"))
807 else if (unformat (line_input, "add"))
809 else if (unformat (line_input, "sa-in %d", &sa_in))
810 vec_add1 (sa_ins, sa_in);
811 else if (unformat (line_input, "sa-out %d", &sa_out))
813 else if (unformat (line_input, "%U",
814 unformat_vnet_sw_interface, vnm, &sw_if_index))
816 else if (unformat (line_input, "%U", unformat_ip_address, &peer))
819 return (clib_error_return (0, "unknown input '%U'",
820 format_unformat_error, line_input));
824 ipsec_tun_protect_update (sw_if_index, &peer, sa_out, sa_ins);
826 ipsec_tun_protect_del (sw_if_index, &peer);
828 unformat_free (line_input);
833 * Protect tunnel with IPSEC
836 VLIB_CLI_COMMAND (ipsec_tun_protect_cmd_node, static) =
838 .path = "ipsec tunnel protect",
839 .function = ipsec_tun_protect_cmd,
840 .short_help = "ipsec tunnel protect <interface> input-sa <SA> output-sa <SA> [add|del]",
841 // this is not MP safe
846 static clib_error_t *
847 ipsec_tun_protect_show (vlib_main_t * vm,
848 unformat_input_t * input, vlib_cli_command_t * cmd)
850 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
856 * show IPSEC tunnel protection
859 VLIB_CLI_COMMAND (ipsec_tun_protect_show_node, static) =
861 .path = "show ipsec protect",
862 .function = ipsec_tun_protect_show,
863 .short_help = "show ipsec protect",
868 ipsec_tun_protect4_hash_show_one (clib_bihash_kv_8_16_t * kv, void *arg)
870 ipsec4_tunnel_kv_t *ikv = (ipsec4_tunnel_kv_t *) kv;
871 vlib_main_t *vm = arg;
873 vlib_cli_output (vm, " %U", format_ipsec4_tunnel_kv, ikv);
875 return (BIHASH_WALK_CONTINUE);
879 ipsec_tun_protect6_hash_show_one (clib_bihash_kv_24_16_t * kv, void *arg)
881 ipsec6_tunnel_kv_t *ikv = (ipsec6_tunnel_kv_t *) kv;
882 vlib_main_t *vm = arg;
884 vlib_cli_output (vm, " %U", format_ipsec6_tunnel_kv, ikv);
886 return (BIHASH_WALK_CONTINUE);
889 static clib_error_t *
890 ipsec_tun_protect_hash_show (vlib_main_t * vm,
891 unformat_input_t * input,
892 vlib_cli_command_t * cmd)
894 ipsec_main_t *im = &ipsec_main;
897 vlib_cli_output (vm, "IPv4:");
899 clib_bihash_foreach_key_value_pair_8_16
900 (&im->tun4_protect_by_key, ipsec_tun_protect4_hash_show_one, vm);
902 vlib_cli_output (vm, "IPv6:");
904 clib_bihash_foreach_key_value_pair_24_16
905 (&im->tun6_protect_by_key, ipsec_tun_protect6_hash_show_one, vm);
912 * show IPSEC tunnel protection hash tables
915 VLIB_CLI_COMMAND (ipsec_tun_protect_hash_show_node, static) =
917 .path = "show ipsec protect-hash",
918 .function = ipsec_tun_protect_hash_show,
919 .short_help = "show ipsec protect-hash",
924 ipsec_cli_init (vlib_main_t * vm)
929 VLIB_INIT_FUNCTION (ipsec_cli_init);
931 static clib_error_t *
932 set_async_mode_command_fn (vlib_main_t * vm, unformat_input_t * input,
933 vlib_cli_command_t * cmd)
935 unformat_input_t _line_input, *line_input = &_line_input;
936 int async_enable = 0;
938 if (!unformat_user (input, unformat_line_input, line_input))
941 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
943 if (unformat (line_input, "on"))
945 else if (unformat (line_input, "off"))
948 return (clib_error_return (0, "unknown input '%U'",
949 format_unformat_error, line_input));
952 vnet_crypto_request_async_mode (async_enable);
953 ipsec_set_async_mode (async_enable);
955 unformat_free (line_input);
960 VLIB_CLI_COMMAND (set_async_mode_command, static) = {
961 .path = "set ipsec async mode",
962 .short_help = "set ipsec async mode on|off",
963 .function = set_async_mode_command_fn,
968 * fd.io coding-style-patch-verification: ON
971 * eval: (c-set-style "gnu")