aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-12-06 05:53:17 +0000
committerDave Barach <openvpp@barachs.net>2019-12-16 23:29:21 +0000
commitf50bac1bb25b02d7f086627c4c0a0709ee0f61d5 (patch)
tree26408a8b3d80f0e2eae7900aa8e49f37ac6de3b8 /src/vnet
parent77cfc0171da0fa2b305378731a5fefd659d8947d (diff)
vppinfra: bihash walk cb typedef and continue/stop controls
Type: feature Change-Id: I28f7a658be3f3beec9ea32635b60d1d3a10d9b06 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet')
-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
14 files changed, 57 insertions, 35 deletions
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);