aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/gbp/gbp_endpoint.c10
-rw-r--r--src/plugins/pppoe/pppoe.c4
-rw-r--r--src/plugins/unittest/bihash_test.c3
-rw-r--r--src/vnet/adj/adj_nbr.c9
-rw-r--r--src/vnet/fib/ip6_fib.c6
-rw-r--r--src/vnet/ip/ip6_ll_table.c8
-rw-r--r--src/vnet/ip/reass/ip4_full_reass.c3
-rw-r--r--src/vnet/ip/reass/ip4_sv_reass.c3
-rw-r--r--src/vnet/ip/reass/ip6_full_reass.c3
-rw-r--r--src/vnet/ip/reass/ip6_sv_reass.c3
-rw-r--r--src/vnet/l2/l2_fib.c12
-rw-r--r--src/vnet/lisp-cp/control.c20
-rw-r--r--src/vnet/lisp-cp/gid_dictionary.c12
-rw-r--r--src/vnet/lisp-cp/gid_dictionary.h6
-rw-r--r--src/vnet/mfib/ip6_mfib.c3
-rw-r--r--src/vnet/session/session_table.c3
-rw-r--r--src/vnet/session/session_table.h1
-rw-r--r--src/vppinfra/bihash_doc.h14
-rw-r--r--src/vppinfra/bihash_template.c7
-rw-r--r--src/vppinfra/bihash_template.h10
20 files changed, 92 insertions, 48 deletions
diff --git a/src/plugins/gbp/gbp_endpoint.c b/src/plugins/gbp/gbp_endpoint.c
index bef67770fd9..c6cab3fbfb8 100644
--- a/src/plugins/gbp/gbp_endpoint.c
+++ b/src/plugins/gbp/gbp_endpoint.c
@@ -1268,8 +1268,8 @@ gbp_endpoint_show_one (index_t gei, void *ctx)
return (WALK_CONTINUE);
}
-static void
-gbp_endpoint_walk_ip_itf (const clib_bihash_kv_24_8_t * kvp, void *arg)
+static int
+gbp_endpoint_walk_ip_itf (clib_bihash_kv_24_8_t * kvp, void *arg)
{
ip46_address_t ip;
vlib_main_t *vm;
@@ -1283,10 +1283,11 @@ gbp_endpoint_walk_ip_itf (const clib_bihash_kv_24_8_t * kvp, void *arg)
format_ip46_address, &ip, IP46_TYPE_ANY,
format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index, kvp->value);
+ return (BIHASH_WALK_CONTINUE);
}
-static void
-gbp_endpoint_walk_mac_itf (const clib_bihash_kv_16_8_t * kvp, void *arg)
+static int
+gbp_endpoint_walk_mac_itf (clib_bihash_kv_16_8_t * kvp, void *arg)
{
mac_address_t mac;
vlib_main_t *vm;
@@ -1300,6 +1301,7 @@ gbp_endpoint_walk_mac_itf (const clib_bihash_kv_16_8_t * kvp, void *arg)
format_mac_address_t, &mac,
format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index, kvp->value);
+ return (BIHASH_WALK_CONTINUE);
}
static clib_error_t *
diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c
index 1f8a7288aeb..46faa1f33eb 100644
--- a/src/plugins/pppoe/pppoe.c
+++ b/src/plugins/pppoe/pppoe.c
@@ -628,7 +628,7 @@ typedef struct pppoe_show_walk_ctx_t_
u32 total_entries;
} pppoe_show_walk_ctx_t;
-static void
+static int
pppoe_show_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
{
pppoe_show_walk_ctx_t *ctx = arg;
@@ -656,6 +656,8 @@ pppoe_show_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
result.fields.session_index == ~0
? -1 : result.fields.session_index);
ctx->total_entries++;
+
+ return (BIHASH_WALK_CONTINUE);
}
/** Display the contents of the PPPoE Fib. */
diff --git a/src/plugins/unittest/bihash_test.c b/src/plugins/unittest/bihash_test.c
index 2dbc6b1b002..03524033884 100644
--- a/src/plugins/unittest/bihash_test.c
+++ b/src/plugins/unittest/bihash_test.c
@@ -244,11 +244,12 @@ test_bihash_threads (bihash_test_main_t * tm)
/*
* Callback to blow up spectacularly if anything remains in the table
*/
-static void
+static int
count_items (BVT (clib_bihash_kv) * kvp, void *notused)
{
_clib_error (CLIB_ERROR_ABORT, 0, 0,
"bihash test FAILED, items left in table!");
+ return (BIHASH_WALK_CONTINUE);
}
static clib_error_t *
diff --git a/src/vnet/adj/adj_nbr.c b/src/vnet/adj/adj_nbr.c
index 2e0888b8c7c..4fb6d9263ae 100644
--- a/src/vnet/adj/adj_nbr.c
+++ b/src/vnet/adj/adj_nbr.c
@@ -521,12 +521,13 @@ typedef struct adj_db_count_ctx_t_ {
u64 count;
} adj_db_count_ctx_t;
-static void
+static int
adj_db_count (BVT(clib_bihash_kv) * kvp,
void *arg)
{
adj_db_count_ctx_t * ctx = arg;
ctx->count++;
+ return (BIHASH_WALK_CONTINUE);
}
u32
@@ -563,14 +564,16 @@ typedef struct adj_walk_ctx_t_
void *awc_ctx;
} adj_walk_ctx_t;
-static void
+static int
adj_nbr_walk_cb (BVT(clib_bihash_kv) * kvp,
void *arg)
{
adj_walk_ctx_t *ctx = arg;
// FIXME: can't stop early...
- ctx->awc_cb(kvp->value, ctx->awc_ctx);
+ if (ADJ_WALK_RC_STOP == ctx->awc_cb(kvp->value, ctx->awc_ctx))
+ return (BIHASH_WALK_STOP);
+ return (BIHASH_WALK_CONTINUE);
}
void
diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c
index 6d0eca4c8d7..06160c5a15a 100644
--- a/src/vnet/fib/ip6_fib.c
+++ b/src/vnet/fib/ip6_fib.c
@@ -589,7 +589,7 @@ typedef struct {
u64 count_by_prefix_length[129];
} count_routes_in_fib_at_prefix_length_arg_t;
-static void
+static int
count_routes_in_fib_at_prefix_length (clib_bihash_kv_24_8_t * kvp,
void *arg)
{
@@ -597,11 +597,13 @@ count_routes_in_fib_at_prefix_length (clib_bihash_kv_24_8_t * kvp,
int mask_width;
if ((kvp->key[2]>>32) != ap->fib_index)
- return;
+ return (BIHASH_WALK_CONTINUE);
mask_width = kvp->key[2] & 0xFF;
ap->count_by_prefix_length[mask_width]++;
+
+ return (BIHASH_WALK_CONTINUE);
}
static clib_error_t *
diff --git a/src/vnet/ip/ip6_ll_table.c b/src/vnet/ip/ip6_ll_table.c
index 3672b635c87..243b94a6c0e 100644
--- a/src/vnet/ip/ip6_ll_table.c
+++ b/src/vnet/ip/ip6_ll_table.c
@@ -210,18 +210,20 @@ typedef struct
u64 count_by_prefix_length[129];
} count_routes_in_fib_at_prefix_length_arg_t;
-static void
-count_routes_in_fib_at_prefix_length (BVT (clib_bihash_kv) * kvp, void *arg)
+static int
+count_routes_in_fib_at_prefix_length (clib_bihash_kv_24_8_t * kvp, void *arg)
{
count_routes_in_fib_at_prefix_length_arg_t *ap = arg;
int mask_width;
if ((kvp->key[2] >> 32) != ap->fib_index)
- return;
+ return (BIHASH_WALK_CONTINUE);
mask_width = kvp->key[2] & 0xFF;
ap->count_by_prefix_length[mask_width]++;
+
+ return (BIHASH_WALK_CONTINUE);
}
static clib_error_t *
diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c
index f6c05466e19..d492e5e4541 100644
--- a/src/vnet/ip/reass/ip4_full_reass.c
+++ b/src/vnet/ip/reass/ip4_full_reass.c
@@ -1365,7 +1365,7 @@ typedef struct
} ip4_rehash_cb_ctx;
#ifndef CLIB_MARCH_VARIANT
-static void
+static int
ip4_rehash_cb (clib_bihash_kv_16_8_t * kv, void *_ctx)
{
ip4_rehash_cb_ctx *ctx = _ctx;
@@ -1373,6 +1373,7 @@ ip4_rehash_cb (clib_bihash_kv_16_8_t * kv, void *_ctx)
{
ctx->failure = 1;
}
+ return (BIHASH_WALK_CONTINUE);
}
static void
diff --git a/src/vnet/ip/reass/ip4_sv_reass.c b/src/vnet/ip/reass/ip4_sv_reass.c
index a926f2adf10..d7130629219 100644
--- a/src/vnet/ip/reass/ip4_sv_reass.c
+++ b/src/vnet/ip/reass/ip4_sv_reass.c
@@ -711,7 +711,7 @@ typedef struct
} ip4_rehash_cb_ctx;
#ifndef CLIB_MARCH_VARIANT
-static void
+static int
ip4_rehash_cb (clib_bihash_kv_16_8_t * kv, void *_ctx)
{
ip4_rehash_cb_ctx *ctx = _ctx;
@@ -719,6 +719,7 @@ ip4_rehash_cb (clib_bihash_kv_16_8_t * kv, void *_ctx)
{
ctx->failure = 1;
}
+ return (BIHASH_WALK_CONTINUE);
}
static void
diff --git a/src/vnet/ip/reass/ip6_full_reass.c b/src/vnet/ip/reass/ip6_full_reass.c
index 7f56d2cc2d6..7bcfdfc9f00 100644
--- a/src/vnet/ip/reass/ip6_full_reass.c
+++ b/src/vnet/ip/reass/ip6_full_reass.c
@@ -1349,7 +1349,7 @@ typedef struct
clib_bihash_48_8_t *new_hash;
} ip6_rehash_cb_ctx;
-static void
+static int
ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
{
ip6_rehash_cb_ctx *ctx = _ctx;
@@ -1357,6 +1357,7 @@ ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
{
ctx->failure = 1;
}
+ return (BIHASH_WALK_CONTINUE);
}
static void
diff --git a/src/vnet/ip/reass/ip6_sv_reass.c b/src/vnet/ip/reass/ip6_sv_reass.c
index 5531d0b3dc4..0837f0606ec 100644
--- a/src/vnet/ip/reass/ip6_sv_reass.c
+++ b/src/vnet/ip/reass/ip6_sv_reass.c
@@ -818,7 +818,7 @@ typedef struct
clib_bihash_48_8_t *new_hash;
} ip6_rehash_cb_ctx;
-static void
+static int
ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
{
ip6_rehash_cb_ctx *ctx = _ctx;
@@ -826,6 +826,7 @@ ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
{
ctx->failure = 1;
}
+ return (BIHASH_WALK_CONTINUE);
}
static void
diff --git a/src/vnet/l2/l2_fib.c b/src/vnet/l2/l2_fib.c
index 600d0c910fc..3e71f771dfe 100644
--- a/src/vnet/l2/l2_fib.c
+++ b/src/vnet/l2/l2_fib.c
@@ -111,7 +111,7 @@ typedef struct l2fib_dump_walk_ctx_t_
l2fib_entry_result_t *l2fe_res;
} l2fib_dump_walk_ctx_t;
-static void
+static int
l2fib_dump_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
{
l2fib_dump_walk_ctx_t *ctx = arg;
@@ -126,6 +126,8 @@ l2fib_dump_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
vec_add1 (ctx->l2fe_key, key);
vec_add1 (ctx->l2fe_res, result);
}
+
+ return (BIHASH_WALK_CONTINUE);
}
void
@@ -158,7 +160,7 @@ typedef struct l2fib_show_walk_ctx_t_
u8 now;
} l2fib_show_walk_ctx_t;
-static void
+static int
l2fib_show_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
{
l2fib_show_walk_ctx_t *ctx = arg;
@@ -186,10 +188,10 @@ l2fib_show_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
u8 *s = NULL;
if (ctx->learn && l2fib_entry_result_is_set_AGE_NOT (&result))
- return; /* skip provisioned macs */
+ return (BIHASH_WALK_CONTINUE); /* skip provisioned macs */
if (ctx->add && !l2fib_entry_result_is_set_AGE_NOT (&result))
- return; /* skip learned macs */
+ return (BIHASH_WALK_CONTINUE); /* skip learned macs */
bd_config = vec_elt_at_index (l2input_main.bd_configs,
key.fields.bd_index);
@@ -219,6 +221,8 @@ l2fib_show_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
ctx->vnm, result.fields.sw_if_index);
vec_free (s);
}
+
+ return (BIHASH_WALK_CONTINUE);
}
/** Display the contents of the l2fib. */
diff --git a/src/vnet/lisp-cp/control.c b/src/vnet/lisp-cp/control.c
index 420a6db4e5a..78750b962df 100644
--- a/src/vnet/lisp-cp/control.c
+++ b/src/vnet/lisp-cp/control.c
@@ -899,16 +899,17 @@ vnet_lisp_add_del_local_mapping (vnet_lisp_add_del_mapping_args_t * a,
return vnet_lisp_map_cache_add_del (a, map_index_result);
}
-static void
+static int
add_l2_arp_bd (BVT (clib_bihash_kv) * kvp, void *arg)
{
u32 **ht = arg;
u32 version = (u32) kvp->key[0];
if (AF_IP6 == version)
- return;
+ return (BIHASH_WALK_CONTINUE);
u32 bd = (u32) (kvp->key[0] >> 32);
hash_set (ht[0], bd, 0);
+ return (BIHASH_WALK_CONTINUE);
}
u32 *
@@ -922,16 +923,17 @@ vnet_lisp_l2_arp_bds_get (void)
return bds;
}
-static void
+static int
add_ndp_bd (BVT (clib_bihash_kv) * kvp, void *arg)
{
u32 **ht = arg;
u32 version = (u32) kvp->key[0];
if (AF_IP4 == version)
- return;
+ return (BIHASH_WALK_CONTINUE);
u32 bd = (u32) (kvp->key[0] >> 32);
hash_set (ht[0], bd, 0);
+ return (BIHASH_WALK_CONTINUE);
}
u32 *
@@ -951,7 +953,7 @@ typedef struct
u32 bd;
} lisp_add_l2_arp_ndp_args_t;
-static void
+static int
add_l2_arp_entry (BVT (clib_bihash_kv) * kvp, void *arg)
{
lisp_add_l2_arp_ndp_args_t *a = arg;
@@ -959,7 +961,7 @@ add_l2_arp_entry (BVT (clib_bihash_kv) * kvp, void *arg)
u32 version = (u32) kvp->key[0];
if (AF_IP6 == version)
- return;
+ return (BIHASH_WALK_CONTINUE);
u32 bd = (u32) (kvp->key[0] >> 32);
@@ -969,6 +971,7 @@ add_l2_arp_entry (BVT (clib_bihash_kv) * kvp, void *arg)
e.ip4 = (u32) kvp->key[1];
vec_add1 (vector[0], e);
}
+ return (BIHASH_WALK_CONTINUE);
}
lisp_api_l2_arp_entry_t *
@@ -986,7 +989,7 @@ vnet_lisp_l2_arp_entries_get_by_bd (u32 bd)
return entries;
}
-static void
+static int
add_ndp_entry (BVT (clib_bihash_kv) * kvp, void *arg)
{
lisp_add_l2_arp_ndp_args_t *a = arg;
@@ -994,7 +997,7 @@ add_ndp_entry (BVT (clib_bihash_kv) * kvp, void *arg)
u32 version = (u32) kvp->key[0];
if (AF_IP4 == version)
- return;
+ return (BIHASH_WALK_CONTINUE);
u32 bd = (u32) (kvp->key[0] >> 32);
@@ -1004,6 +1007,7 @@ add_ndp_entry (BVT (clib_bihash_kv) * kvp, void *arg)
clib_memcpy (e.ip6, &kvp->key[1], 16);
vec_add1 (vector[0], e);
}
+ return (BIHASH_WALK_CONTINUE);
}
lisp_api_ndp_entry_t *
diff --git a/src/vnet/lisp-cp/gid_dictionary.c b/src/vnet/lisp-cp/gid_dictionary.c
index 3fd98c737c8..c1b4adacf22 100644
--- a/src/vnet/lisp-cp/gid_dictionary.c
+++ b/src/vnet/lisp-cp/gid_dictionary.c
@@ -31,7 +31,7 @@ static u32 ip4_lookup (gid_ip4_table_t * db, u32 vni, ip_prefix_t * key);
static u32 ip6_lookup (gid_ip6_table_t * db, u32 vni, ip_prefix_t * key);
-static void
+static int
foreach_sfib4_subprefix (BVT (clib_bihash_kv) * kvp, void *arg)
{
sfib_entry_arg_t *a = arg;
@@ -51,6 +51,7 @@ foreach_sfib4_subprefix (BVT (clib_bihash_kv) * kvp, void *arg)
/* found sub-prefix of src prefix */
(a->cb) (kvp->value, a->arg);
}
+ return (BIHASH_WALK_CONTINUE);
}
static void
@@ -77,7 +78,7 @@ gid_dict_foreach_ip4_subprefix (gid_dictionary_t * db, u32 vni,
foreach_sfib4_subprefix, &a);
}
-static void
+static int
foreach_sfib6_subprefix (BVT (clib_bihash_kv) * kvp, void *arg)
{
sfib_entry_arg_t *a = arg;
@@ -94,6 +95,7 @@ foreach_sfib6_subprefix (BVT (clib_bihash_kv) * kvp, void *arg)
/* found sub-prefix of src prefix */
(a->cb) (kvp->value, a->arg);
}
+ return (BIHASH_WALK_CONTINUE);
}
static void
@@ -139,9 +141,9 @@ gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid,
}
void
-gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db, void (*cb)
- (BVT (clib_bihash_kv) * kvp, void *arg),
- void *ht)
+gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db,
+ BV (clib_bihash_foreach_key_value_pair_cb)
+ cb, void *ht)
{
gid_l2_arp_ndp_table_t *tab = &db->arp_ndp_table;
BV (clib_bihash_foreach_key_value_pair) (&tab->arp_ndp_lookup_table, cb,
diff --git a/src/vnet/lisp-cp/gid_dictionary.h b/src/vnet/lisp-cp/gid_dictionary.h
index 3f8500e56a7..5154b3a5874 100644
--- a/src/vnet/lisp-cp/gid_dictionary.h
+++ b/src/vnet/lisp-cp/gid_dictionary.h
@@ -146,9 +146,9 @@ gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid,
foreach_subprefix_match_cb_t cb, void *arg);
void
-gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db, void (*cb)
- (BVT (clib_bihash_kv) * kvp, void *arg),
- void *ht);
+gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db,
+ BV (clib_bihash_foreach_key_value_pair_cb)
+ cb, void *ht);
#endif /* VNET_LISP_GPE_GID_DICTIONARY_H_ */
diff --git a/src/vnet/mfib/ip6_mfib.c b/src/vnet/mfib/ip6_mfib.c
index 690f4ed9dfd..6b3b8d90fbe 100644
--- a/src/vnet/mfib/ip6_mfib.c
+++ b/src/vnet/mfib/ip6_mfib.c
@@ -609,7 +609,7 @@ typedef struct ip6_mfib_walk_ctx_t_
void *i6w_ctx;
} ip6_mfib_walk_ctx_t;
-static void
+static int
ip6_mfib_walk_cb (clib_bihash_kv_40_8_t * kvp,
void *arg)
{
@@ -619,6 +619,7 @@ ip6_mfib_walk_cb (clib_bihash_kv_40_8_t * kvp,
{
ctx->i6w_fn(kvp->value, ctx->i6w_ctx);
}
+ return (BIHASH_WALK_CONTINUE);
}
void
diff --git a/src/vnet/session/session_table.c b/src/vnet/session/session_table.c
index 1f586f8cba2..d619fa580d8 100644
--- a/src/vnet/session/session_table.c
+++ b/src/vnet/session/session_table.c
@@ -139,11 +139,12 @@ typedef struct _ip4_session_table_walk_ctx_t
void *ctx;
} ip4_session_table_walk_ctx_t;
-void
+static int
ip4_session_table_walk_cb (clib_bihash_kv_16_8_t * kvp, void *arg)
{
ip4_session_table_walk_ctx_t *ctx = arg;
ctx->fn (kvp, ctx->ctx);
+ return (BIHASH_WALK_CONTINUE);
}
void
diff --git a/src/vnet/session/session_table.h b/src/vnet/session/session_table.h
index 4aaa900f0c9..d3af566a77d 100644
--- a/src/vnet/session/session_table.h
+++ b/src/vnet/session/session_table.h
@@ -60,7 +60,6 @@ typedef struct _session_lookup_table
typedef int (*ip4_session_table_walk_fn_t) (clib_bihash_kv_16_8_t * kvp,
void *ctx);
-void ip4_session_table_walk_cb (clib_bihash_kv_16_8_t * kvp, void *arg);
void ip4_session_table_walk (clib_bihash_16_8_t * hash,
ip4_session_table_walk_fn_t fn, void *arg);
diff --git a/src/vppinfra/bihash_doc.h b/src/vppinfra/bihash_doc.h
index a7e70e9695c..da8c832f160 100644
--- a/src/vppinfra/bihash_doc.h
+++ b/src/vppinfra/bihash_doc.h
@@ -165,17 +165,25 @@ void clib_bihash_prefetch_data (clib_bihash * h, u64 hash);
int clib_bihash_search_inline_2
(clib_bihash * h, clib_bihash_kv * search_key, clib_bihash_kv * valuep);
+/* Calback function for walking a bihash table
+ *
+ * @param kv - KV pair visited
+ * @param ctx - Context passed to the walk
+ * @return BIHASH_WALK_CONTINUE to continue BIHASH_WALK_STOP to stop
+ */
+typedef int (*clib_bihash_foreach_key_value_pair_cb) (clib_bihash_kv * kv,
+ void *ctx);
+
/** Visit active (key,value) pairs in a bi-hash table
@param h - the bi-hash table to search
@param callback - function to call with each active (key,value) pair
@param arg - arbitrary second argument passed to the callback function
First argument is the (key,value) pair to visit
- @note Trying to supply a proper function prototype for the
- callback function appears to be a fool's errand.
*/
void clib_bihash_foreach_key_value_pair (clib_bihash * h,
- void *callback, void *arg);
+ clib_bihash_foreach_key_value_pair_cb
+ * callback, void *arg);
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c
index 97c4cd08eb1..b090041ad29 100644
--- a/src/vppinfra/bihash_template.c
+++ b/src/vppinfra/bihash_template.c
@@ -906,12 +906,12 @@ u8 *BV (format_bihash) (u8 * s, va_list * args)
}
void BV (clib_bihash_foreach_key_value_pair)
- (BVT (clib_bihash) * h, void *callback, void *arg)
+ (BVT (clib_bihash) * h,
+ BV (clib_bihash_foreach_key_value_pair_cb) cb, void *arg)
{
int i, j, k;
BVT (clib_bihash_bucket) * b;
BVT (clib_bihash_value) * v;
- void (*fp) (BVT (clib_bihash_kv) *, void *) = callback;
if (PREDICT_FALSE (alloc_arena (h) == 0))
return;
@@ -930,7 +930,8 @@ void BV (clib_bihash_foreach_key_value_pair)
if (BV (clib_bihash_is_free) (&v->kvp[k]))
continue;
- (*fp) (&v->kvp[k], arg);
+ if (BIHASH_WALK_STOP == cb (&v->kvp[k], arg))
+ return;
/*
* In case the callback deletes the last entry in the bucket...
*/
diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h
index ebd70c03371..f11e6d506ab 100644
--- a/src/vppinfra/bihash_template.h
+++ b/src/vppinfra/bihash_template.h
@@ -328,8 +328,16 @@ int BV (clib_bihash_search) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * search_v,
BVT (clib_bihash_kv) * return_v);
+#define BIHASH_WALK_STOP 0
+#define BIHASH_WALK_CONTINUE 1
+
+typedef
+ int (*BV (clib_bihash_foreach_key_value_pair_cb)) (BVT (clib_bihash_kv) *,
+ void *);
void BV (clib_bihash_foreach_key_value_pair) (BVT (clib_bihash) * h,
- void *callback, void *arg);
+ BV
+ (clib_bihash_foreach_key_value_pair_cb)
+ cb, void *arg);
void *clib_all_bihash_set_heap (void);
void clib_bihash_copied (void *dst, void *src);