aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec_cli.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-05-24 16:17:50 +0000
committerNeale Ranns <nranns@cisco.com>2020-10-05 09:06:36 +0000
commit7b4e52f88fdfd7b785a2741d3b61050040d8561d (patch)
treef80271d2f297c99b15fb1a25141cd4be4357e07f /src/vnet/ipsec/ipsec_cli.c
parent149fd3fbd069a5f7be86e68472578ee7af229cb6 (diff)
ipsec: Use bihash for tunnel lookup
Type: improvement Change-Id: I0c82722dfce990345fe6eeecdb335678543367e0 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ipsec/ipsec_cli.c')
-rw-r--r--src/vnet/ipsec/ipsec_cli.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/vnet/ipsec/ipsec_cli.c b/src/vnet/ipsec/ipsec_cli.c
index 0d1ab033aec..937e0f6b2e4 100644
--- a/src/vnet/ipsec/ipsec_cli.c
+++ b/src/vnet/ipsec/ipsec_cli.c
@@ -1037,6 +1037,28 @@ VLIB_CLI_COMMAND (ipsec_tun_protect_show_node, static) =
};
/* *INDENT-ON* */
+static int
+ipsec_tun_protect4_hash_show_one (clib_bihash_kv_8_8_t * kv, void *arg)
+{
+ ipsec4_tunnel_kv_t *ikv = (ipsec4_tunnel_kv_t *) kv;
+ vlib_main_t *vm = arg;
+
+ vlib_cli_output (vm, " %U", format_ipsec4_tunnel_kv, ikv);
+
+ return (BIHASH_WALK_CONTINUE);
+}
+
+static int
+ipsec_tun_protect6_hash_show_one (clib_bihash_kv_24_8_t * kv, void *arg)
+{
+ ipsec6_tunnel_kv_t *ikv = (ipsec6_tunnel_kv_t *) kv;
+ vlib_main_t *vm = arg;
+
+ vlib_cli_output (vm, " %U", format_ipsec6_tunnel_kv, ikv);
+
+ return (BIHASH_WALK_CONTINUE);
+}
+
static clib_error_t *
ipsec_tun_protect_hash_show (vlib_main_t * vm,
unformat_input_t * input,
@@ -1045,33 +1067,15 @@ ipsec_tun_protect_hash_show (vlib_main_t * vm,
ipsec_main_t *im = &ipsec_main;
{
- ipsec_tun_lkup_result_t value;
- ipsec4_tunnel_key_t key;
-
vlib_cli_output (vm, "IPv4:");
- /* *INDENT-OFF* */
- hash_foreach(key.as_u64, value.as_u64, im->tun4_protect_by_key,
- ({
- vlib_cli_output (vm, " %U", format_ipsec4_tunnel_key, &key);
- vlib_cli_output (vm, " tun:%d sa:%d", value.tun_index, value.sa_index);
- }));
- /* *INDENT-ON* */
- }
-
- {
- ipsec_tun_lkup_result_t value;
- ipsec6_tunnel_key_t *key;
+ clib_bihash_foreach_key_value_pair_8_8
+ (&im->tun4_protect_by_key, ipsec_tun_protect4_hash_show_one, vm);
vlib_cli_output (vm, "IPv6:");
- /* *INDENT-OFF* */
- hash_foreach_mem(key, value.as_u64, im->tun6_protect_by_key,
- ({
- vlib_cli_output (vm, " %U", format_ipsec6_tunnel_key, key);
- vlib_cli_output (vm, " tun:%d sa:%d", value.tun_index, value.sa_index);
- }));
- /* *INDENT-ON* */
+ clib_bihash_foreach_key_value_pair_24_8
+ (&im->tun6_protect_by_key, ipsec_tun_protect6_hash_show_one, vm);
}
return NULL;