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;
164 else if (unformat (line_input, "async"))
165 flags |= IPSEC_SA_FLAG_IS_ASYNC;
168 error = clib_error_return (0, "parse error: '%U'",
169 format_unformat_error, line_input);
176 error = clib_error_return (0, "missing id");
184 error = clib_error_return (0, "missing spi");
187 rv = ipsec_sa_add_and_lock (id, spi, proto, crypto_alg, &ck, integ_alg,
188 &ik, flags, clib_host_to_net_u32 (salt),
189 udp_src, udp_dst, &tun, &sai);
193 rv = ipsec_sa_unlock_id (id);
197 error = clib_error_return (0, "failed: %d", rv);
200 unformat_free (line_input);
206 VLIB_CLI_COMMAND (ipsec_sa_add_del_command, static) = {
209 "ipsec sa [add|del]",
210 .function = ipsec_sa_add_del_command_fn,
214 static clib_error_t *
215 ipsec_spd_add_del_command_fn (vlib_main_t * vm,
216 unformat_input_t * input,
217 vlib_cli_command_t * cmd)
219 unformat_input_t _line_input, *line_input = &_line_input;
222 clib_error_t *error = NULL;
224 if (!unformat_user (input, unformat_line_input, line_input))
227 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
229 if (unformat (line_input, "add"))
231 else if (unformat (line_input, "del"))
233 else if (unformat (line_input, "%u", &spd_id))
237 error = clib_error_return (0, "parse error: '%U'",
238 format_unformat_error, line_input);
245 error = clib_error_return (0, "please specify SPD ID");
249 ipsec_add_del_spd (vm, spd_id, is_add);
252 unformat_free (line_input);
258 VLIB_CLI_COMMAND (ipsec_spd_add_del_command, static) = {
261 "ipsec spd [add|del] <id>",
262 .function = ipsec_spd_add_del_command_fn,
267 static clib_error_t *
268 ipsec_policy_add_del_command_fn (vlib_main_t * vm,
269 unformat_input_t * input,
270 vlib_cli_command_t * cmd)
272 unformat_input_t _line_input, *line_input = &_line_input;
275 u32 tmp, tmp2, stat_index, local_range_set, remote_range_set;
276 clib_error_t *error = NULL;
279 clib_memset (&p, 0, sizeof (p));
280 p.lport.stop = p.rport.stop = ~0;
281 remote_range_set = local_range_set = is_outbound = 0;
282 p.protocol = IPSEC_POLICY_PROTOCOL_ANY;
284 if (!unformat_user (input, unformat_line_input, line_input))
287 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
289 if (unformat (line_input, "add"))
291 else if (unformat (line_input, "del"))
293 else if (unformat (line_input, "ip6"))
295 else if (unformat (line_input, "spd %u", &p.id))
297 else if (unformat (line_input, "inbound"))
299 else if (unformat (line_input, "outbound"))
301 else if (unformat (line_input, "priority %d", &p.priority))
303 else if (unformat (line_input, "protocol %u", &tmp))
304 p.protocol = (u8) tmp;
307 (line_input, "action %U", unformat_ipsec_policy_action,
310 if (p.policy == IPSEC_POLICY_ACTION_RESOLVE)
312 error = clib_error_return (0, "unsupported action: 'resolve'");
316 else if (unformat (line_input, "sa %u", &p.sa_id))
318 else if (unformat (line_input, "local-ip-range %U - %U",
319 unformat_ip4_address, &p.laddr.start.ip4,
320 unformat_ip4_address, &p.laddr.stop.ip4))
322 else if (unformat (line_input, "remote-ip-range %U - %U",
323 unformat_ip4_address, &p.raddr.start.ip4,
324 unformat_ip4_address, &p.raddr.stop.ip4))
325 remote_range_set = 1;
326 else if (unformat (line_input, "local-ip-range %U - %U",
327 unformat_ip6_address, &p.laddr.start.ip6,
328 unformat_ip6_address, &p.laddr.stop.ip6))
333 else if (unformat (line_input, "remote-ip-range %U - %U",
334 unformat_ip6_address, &p.raddr.start.ip6,
335 unformat_ip6_address, &p.raddr.stop.ip6))
338 remote_range_set = 1;
340 else if (unformat (line_input, "local-port-range %u - %u", &tmp, &tmp2))
346 if (unformat (line_input, "remote-port-range %u - %u", &tmp, &tmp2))
353 error = clib_error_return (0, "parse error: '%U'",
354 format_unformat_error, line_input);
359 if (!remote_range_set)
362 clib_memset (&p.raddr.stop.ip6, 0xff, 16);
364 clib_memset (&p.raddr.stop.ip4, 0xff, 4);
366 if (!local_range_set)
369 clib_memset (&p.laddr.stop.ip6, 0xff, 16);
371 clib_memset (&p.laddr.stop.ip4, 0xff, 4);
374 rv = ipsec_policy_mk_type (is_outbound, p.is_ipv6, p.policy, &p.type);
378 error = clib_error_return (0, "unsupported policy type for:",
379 " outboud:%s %s action:%U",
380 (is_outbound ? "yes" : "no"),
381 (p.is_ipv6 ? "IPv4" : "IPv6"),
382 format_ipsec_policy_action, p.policy);
386 rv = ipsec_add_del_policy (vm, &p, is_add, &stat_index);
389 vlib_cli_output (vm, "policy-index:%d", stat_index);
391 vlib_cli_output (vm, "error:%d", rv);
394 unformat_free (line_input);
400 VLIB_CLI_COMMAND (ipsec_policy_add_del_command, static) = {
401 .path = "ipsec policy",
403 "ipsec policy [add|del] spd <id> priority <n> ",
404 .function = ipsec_policy_add_del_command_fn,
409 ipsec_sa_show_all (vlib_main_t * vm, ipsec_main_t * im, u8 detail)
414 pool_foreach_index (sai, ipsec_sa_pool)
416 vlib_cli_output (vm, "%U", format_ipsec_sa, sai,
417 (detail ? IPSEC_FORMAT_DETAIL : IPSEC_FORMAT_BRIEF));
423 ipsec_spd_show_all (vlib_main_t * vm, ipsec_main_t * im)
428 pool_foreach_index (spdi, im->spds) {
429 vlib_cli_output(vm, "%U", format_ipsec_spd, spdi);
432 if (im->output_flow_cache_flag)
434 vlib_cli_output (vm, "%U", format_ipsec_out_spd_flow_cache);
436 if (im->input_flow_cache_flag)
438 vlib_cli_output (vm, "%U", format_ipsec_in_spd_flow_cache);
444 ipsec_spd_bindings_show_all (vlib_main_t * vm, ipsec_main_t * im)
446 u32 spd_id, sw_if_index;
449 vlib_cli_output (vm, "SPD Bindings:");
452 hash_foreach(sw_if_index, spd_id, im->spd_index_by_sw_if_index, ({
453 spd = pool_elt_at_index (im->spds, spd_id);
454 vlib_cli_output (vm, " %d -> %U", spd->id,
455 format_vnet_sw_if_index_name, im->vnet_main,
462 ipsec_tun_protect_show_one (index_t itpi, void *ctx)
464 vlib_cli_output (ctx, "%U", format_ipsec_tun_protect_index, itpi);
466 return (WALK_CONTINUE);
470 ipsec_tunnel_show_all (vlib_main_t * vm)
472 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
475 static clib_error_t *
476 show_ipsec_command_fn (vlib_main_t * vm,
477 unformat_input_t * input, vlib_cli_command_t * cmd)
479 ipsec_main_t *im = &ipsec_main;
481 ipsec_sa_show_all (vm, im, 0);
482 ipsec_spd_show_all (vm, im);
483 ipsec_spd_bindings_show_all (vm, im);
484 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
486 vlib_cli_output (vm, "IPSec async mode: %s",
487 (im->async_mode ? "on" : "off"));
493 VLIB_CLI_COMMAND (show_ipsec_command, static) = {
494 .path = "show ipsec all",
495 .short_help = "show ipsec all",
496 .function = show_ipsec_command_fn,
500 static clib_error_t *
501 show_ipsec_sa_command_fn (vlib_main_t * vm,
502 unformat_input_t * input, vlib_cli_command_t * cmd)
504 ipsec_main_t *im = &ipsec_main;
508 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
510 if (unformat (input, "%u", &sai))
512 if (unformat (input, "detail"))
519 ipsec_sa_show_all (vm, im, detail);
521 vlib_cli_output (vm, "%U", format_ipsec_sa, sai,
522 IPSEC_FORMAT_DETAIL | IPSEC_FORMAT_INSECURE);
527 static clib_error_t *
528 clear_ipsec_sa_command_fn (vlib_main_t * vm,
529 unformat_input_t * input, vlib_cli_command_t * cmd)
533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
535 if (unformat (input, "%u", &sai))
544 pool_foreach_index (sai, ipsec_sa_pool)
546 ipsec_sa_clear (sai);
552 if (pool_is_free_index (ipsec_sa_pool, sai))
553 return clib_error_return (0, "unknown SA index: %d", sai);
555 ipsec_sa_clear (sai);
562 VLIB_CLI_COMMAND (show_ipsec_sa_command, static) = {
563 .path = "show ipsec sa",
564 .short_help = "show ipsec sa [index]",
565 .function = show_ipsec_sa_command_fn,
568 VLIB_CLI_COMMAND (clear_ipsec_sa_command, static) = {
569 .path = "clear ipsec sa",
570 .short_help = "clear ipsec sa [index]",
571 .function = clear_ipsec_sa_command_fn,
575 static clib_error_t *
576 show_ipsec_spd_command_fn (vlib_main_t * vm,
577 unformat_input_t * input, vlib_cli_command_t * cmd)
579 ipsec_main_t *im = &ipsec_main;
580 u8 show_bindings = 0;
583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
585 if (unformat (input, "%u", &spdi))
587 else if (unformat (input, "bindings"))
594 ipsec_spd_bindings_show_all (vm, im);
596 vlib_cli_output (vm, "%U", format_ipsec_spd, spdi);
598 ipsec_spd_show_all (vm, im);
604 VLIB_CLI_COMMAND (show_ipsec_spd_command, static) = {
605 .path = "show ipsec spd",
606 .short_help = "show ipsec spd [index]",
607 .function = show_ipsec_spd_command_fn,
611 static clib_error_t *
612 show_ipsec_tunnel_command_fn (vlib_main_t * vm,
613 unformat_input_t * input,
614 vlib_cli_command_t * cmd)
616 ipsec_tunnel_show_all (vm);
622 VLIB_CLI_COMMAND (show_ipsec_tunnel_command, static) = {
623 .path = "show ipsec tunnel",
624 .short_help = "show ipsec tunnel",
625 .function = show_ipsec_tunnel_command_fn,
629 static clib_error_t *
630 ipsec_show_backends_command_fn (vlib_main_t * vm,
631 unformat_input_t * input,
632 vlib_cli_command_t * cmd)
634 ipsec_main_t *im = &ipsec_main;
637 (void) unformat (input, "verbose %u", &verbose);
639 vlib_cli_output (vm, "IPsec AH backends available:");
640 u8 *s = format (NULL, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
641 ipsec_ah_backend_t *ab;
643 pool_foreach (ab, im->ah_backends) {
644 s = format (s, "%=25s %=25u %=10s\n", ab->name, ab - im->ah_backends,
645 ab - im->ah_backends == im->ah_current_backend ? "yes" : "no");
648 n = vlib_get_node (vm, ab->ah4_encrypt_node_index);
649 s = format (s, " enc4 %s (next %d)\n", n->name, ab->ah4_encrypt_next_index);
650 n = vlib_get_node (vm, ab->ah4_decrypt_node_index);
651 s = format (s, " dec4 %s (next %d)\n", n->name, ab->ah4_decrypt_next_index);
652 n = vlib_get_node (vm, ab->ah6_encrypt_node_index);
653 s = format (s, " enc6 %s (next %d)\n", n->name, ab->ah6_encrypt_next_index);
654 n = vlib_get_node (vm, ab->ah6_decrypt_node_index);
655 s = format (s, " dec6 %s (next %d)\n", n->name, ab->ah6_decrypt_next_index);
659 vlib_cli_output (vm, "%v", s);
661 vlib_cli_output (vm, "IPsec ESP backends available:");
662 s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
663 ipsec_esp_backend_t *eb;
665 pool_foreach (eb, im->esp_backends) {
666 s = format (s, "%=25s %=25u %=10s\n", eb->name, eb - im->esp_backends,
667 eb - im->esp_backends == im->esp_current_backend ? "yes"
671 n = vlib_get_node (vm, eb->esp4_encrypt_node_index);
672 s = format (s, " enc4 %s (next %d)\n", n->name, eb->esp4_encrypt_next_index);
673 n = vlib_get_node (vm, eb->esp4_decrypt_node_index);
674 s = format (s, " dec4 %s (next %d)\n", n->name, eb->esp4_decrypt_next_index);
675 n = vlib_get_node (vm, eb->esp6_encrypt_node_index);
676 s = format (s, " enc6 %s (next %d)\n", n->name, eb->esp6_encrypt_next_index);
677 n = vlib_get_node (vm, eb->esp6_decrypt_node_index);
678 s = format (s, " dec6 %s (next %d)\n", n->name, eb->esp6_decrypt_next_index);
682 vlib_cli_output (vm, "%v", s);
689 VLIB_CLI_COMMAND (ipsec_show_backends_command, static) = {
690 .path = "show ipsec backends",
691 .short_help = "show ipsec backends",
692 .function = ipsec_show_backends_command_fn,
696 static clib_error_t *
697 ipsec_select_backend_command_fn (vlib_main_t * vm,
698 unformat_input_t * input,
699 vlib_cli_command_t * cmd)
701 unformat_input_t _line_input, *line_input = &_line_input;
702 ipsec_main_t *im = &ipsec_main;
706 error = ipsec_rsc_in_use (im);
711 /* Get a line of input. */
712 if (!unformat_user (input, unformat_line_input, line_input))
715 if (unformat (line_input, "ah"))
717 if (unformat (line_input, "%u", &backend_index))
719 if (ipsec_select_ah_backend (im, backend_index) < 0)
721 return clib_error_return (0, "Invalid AH backend index `%u'",
727 return clib_error_return (0, "Invalid backend index `%U'",
728 format_unformat_error, line_input);
731 else if (unformat (line_input, "esp"))
733 if (unformat (line_input, "%u", &backend_index))
735 if (ipsec_select_esp_backend (im, backend_index) < 0)
737 return clib_error_return (0, "Invalid ESP backend index `%u'",
743 return clib_error_return (0, "Invalid backend index `%U'",
744 format_unformat_error, line_input);
749 return clib_error_return (0, "Unknown input `%U'",
750 format_unformat_error, line_input);
757 VLIB_CLI_COMMAND (ipsec_select_backend_command, static) = {
758 .path = "ipsec select backend",
759 .short_help = "ipsec select backend <ah|esp> <backend index>",
760 .function = ipsec_select_backend_command_fn,
765 static clib_error_t *
766 clear_ipsec_counters_command_fn (vlib_main_t * vm,
767 unformat_input_t * input,
768 vlib_cli_command_t * cmd)
770 vlib_clear_combined_counters (&ipsec_spd_policy_counters);
771 vlib_clear_combined_counters (&ipsec_sa_counters);
772 vlib_clear_simple_counters (&ipsec_sa_lost_counters);
778 VLIB_CLI_COMMAND (clear_ipsec_counters_command, static) = {
779 .path = "clear ipsec counters",
780 .short_help = "clear ipsec counters",
781 .function = clear_ipsec_counters_command_fn,
785 static clib_error_t *
786 ipsec_tun_protect_cmd (vlib_main_t * vm,
787 unformat_input_t * input, vlib_cli_command_t * cmd)
789 unformat_input_t _line_input, *line_input = &_line_input;
790 u32 sw_if_index, is_del, sa_in, sa_out, *sa_ins = NULL;
791 ip_address_t peer = { };
796 vnm = vnet_get_main ();
798 if (!unformat_user (input, unformat_line_input, line_input))
801 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
803 if (unformat (line_input, "del"))
805 else if (unformat (line_input, "add"))
807 else if (unformat (line_input, "sa-in %d", &sa_in))
808 vec_add1 (sa_ins, sa_in);
809 else if (unformat (line_input, "sa-out %d", &sa_out))
811 else if (unformat (line_input, "%U",
812 unformat_vnet_sw_interface, vnm, &sw_if_index))
814 else if (unformat (line_input, "%U", unformat_ip_address, &peer))
817 return (clib_error_return (0, "unknown input '%U'",
818 format_unformat_error, line_input));
822 ipsec_tun_protect_update (sw_if_index, &peer, sa_out, sa_ins);
824 ipsec_tun_protect_del (sw_if_index, &peer);
826 unformat_free (line_input);
831 * Protect tunnel with IPSEC
834 VLIB_CLI_COMMAND (ipsec_tun_protect_cmd_node, static) =
836 .path = "ipsec tunnel protect",
837 .function = ipsec_tun_protect_cmd,
838 .short_help = "ipsec tunnel protect <interface> input-sa <SA> output-sa <SA> [add|del]",
839 // this is not MP safe
844 static clib_error_t *
845 ipsec_tun_protect_show (vlib_main_t * vm,
846 unformat_input_t * input, vlib_cli_command_t * cmd)
848 ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm);
854 * show IPSEC tunnel protection
857 VLIB_CLI_COMMAND (ipsec_tun_protect_show_node, static) =
859 .path = "show ipsec protect",
860 .function = ipsec_tun_protect_show,
861 .short_help = "show ipsec protect",
866 ipsec_tun_protect4_hash_show_one (clib_bihash_kv_8_16_t * kv, void *arg)
868 ipsec4_tunnel_kv_t *ikv = (ipsec4_tunnel_kv_t *) kv;
869 vlib_main_t *vm = arg;
871 vlib_cli_output (vm, " %U", format_ipsec4_tunnel_kv, ikv);
873 return (BIHASH_WALK_CONTINUE);
877 ipsec_tun_protect6_hash_show_one (clib_bihash_kv_24_16_t * kv, void *arg)
879 ipsec6_tunnel_kv_t *ikv = (ipsec6_tunnel_kv_t *) kv;
880 vlib_main_t *vm = arg;
882 vlib_cli_output (vm, " %U", format_ipsec6_tunnel_kv, ikv);
884 return (BIHASH_WALK_CONTINUE);
887 static clib_error_t *
888 ipsec_tun_protect_hash_show (vlib_main_t * vm,
889 unformat_input_t * input,
890 vlib_cli_command_t * cmd)
892 ipsec_main_t *im = &ipsec_main;
895 vlib_cli_output (vm, "IPv4:");
897 clib_bihash_foreach_key_value_pair_8_16
898 (&im->tun4_protect_by_key, ipsec_tun_protect4_hash_show_one, vm);
900 vlib_cli_output (vm, "IPv6:");
902 clib_bihash_foreach_key_value_pair_24_16
903 (&im->tun6_protect_by_key, ipsec_tun_protect6_hash_show_one, vm);
910 * show IPSEC tunnel protection hash tables
913 VLIB_CLI_COMMAND (ipsec_tun_protect_hash_show_node, static) =
915 .path = "show ipsec protect-hash",
916 .function = ipsec_tun_protect_hash_show,
917 .short_help = "show ipsec protect-hash",
922 ipsec_cli_init (vlib_main_t * vm)
927 VLIB_INIT_FUNCTION (ipsec_cli_init);
929 static clib_error_t *
930 set_async_mode_command_fn (vlib_main_t * vm, unformat_input_t * input,
931 vlib_cli_command_t * cmd)
933 unformat_input_t _line_input, *line_input = &_line_input;
934 int async_enable = 0;
936 if (!unformat_user (input, unformat_line_input, line_input))
939 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
941 if (unformat (line_input, "on"))
943 else if (unformat (line_input, "off"))
946 return (clib_error_return (0, "unknown input '%U'",
947 format_unformat_error, line_input));
950 ipsec_set_async_mode (async_enable);
952 unformat_free (line_input);
957 VLIB_CLI_COMMAND (set_async_mode_command, static) = {
958 .path = "set ipsec async mode",
959 .short_help = "set ipsec async mode on|off",
960 .function = set_async_mode_command_fn,
965 * fd.io coding-style-patch-verification: ON
968 * eval: (c-set-style "gnu")