Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vppinfra: fix coverity issue CID 323952
[vpp.git]
/
src
/
vppinfra
/
bihash_template.h
diff --git
a/src/vppinfra/bihash_template.h
b/src/vppinfra/bihash_template.h
index
a6990ff
..
e8a2c01
100644
(file)
--- a/
src/vppinfra/bihash_template.h
+++ b/
src/vppinfra/bihash_template.h
@@
-34,7
+34,6
@@
#endif
#ifdef BIHASH_32_64_SVM
#endif
#ifdef BIHASH_32_64_SVM
-#undef HAVE_MEMFD_CREATE
#include <vppinfra/linux/syscall.h>
#include <fcntl.h>
#define F_LINUX_SPECIFIC_BASE 1024
#include <vppinfra/linux/syscall.h>
#include <fcntl.h>
#define F_LINUX_SPECIFIC_BASE 1024
@@
-156,6
+155,7
@@
BVS (clib_bihash)
u32 log2_nbuckets;
u64 memory_size;
u8 *name;
u32 log2_nbuckets;
u64 memory_size;
u8 *name;
+ format_function_t *fmt_fn;
void *heap;
BVT (clib_bihash_alloc_chunk) * chunks;
void *heap;
BVT (clib_bihash_alloc_chunk) * chunks;
@@
-170,11
+170,12
@@
BVS (clib_bihash)
u64 alloc_arena; /* Base of the allocation arena */
volatile u8 instantiated;
u64 alloc_arena; /* Base of the allocation arena */
volatile u8 instantiated;
+ u8 dont_add_to_all_bihash_list;
/**
* A custom format function to print the Key and Value of bihash_key instead of default hexdump
*/
/**
* A custom format function to print the Key and Value of bihash_key instead of default hexdump
*/
- format_function_t *fmt_fn;
+ format_function_t *
kvp_
fmt_fn;
/** Optional statistics-gathering callback */
#if BIHASH_ENABLE_STATS
/** Optional statistics-gathering callback */
#if BIHASH_ENABLE_STATS
@@
-192,7
+193,7
@@
typedef struct
char *name;
u32 nbuckets;
uword memory_size;
char *name;
u32 nbuckets;
uword memory_size;
- format_function_t *fmt_fn;
+ format_function_t *
kvp_
fmt_fn;
u8 instantiate_immediately;
u8 dont_add_to_all_bihash_list;
} BVT (clib_bihash_init2_args);
u8 instantiate_immediately;
u8 dont_add_to_all_bihash_list;
} BVT (clib_bihash_init2_args);
@@
-333,6
+334,9
@@
static inline uword BV (clib_bihash_get_offset) (BVT (clib_bihash) * h,
return vp - hp;
}
return vp - hp;
}
+#define BIHASH_ADD 1
+#define BIHASH_DEL 0
+
void BV (clib_bihash_init)
(BVT (clib_bihash) * h, char *name, u32 nbuckets, uword memory_size);
void BV (clib_bihash_init)
(BVT (clib_bihash) * h, char *name, u32 nbuckets, uword memory_size);
@@
-346,22
+350,31
@@
void BV (clib_bihash_responder_init_svm)
#endif
void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h,
#endif
void BV (clib_bihash_set_kvp_format_fn) (BVT (clib_bihash) * h,
- format_function_t * fmt_fn);
+ format_function_t *
kvp_
fmt_fn);
void BV (clib_bihash_free) (BVT (clib_bihash) * h);
int BV (clib_bihash_add_del) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * add_v, int is_add);
void BV (clib_bihash_free) (BVT (clib_bihash) * h);
int BV (clib_bihash_add_del) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * add_v, int is_add);
+
+int BV (clib_bihash_add_del_with_hash) (BVT (clib_bihash) * h,
+ BVT (clib_bihash_kv) * add_v, u64 hash,
+ int is_add);
int BV (clib_bihash_add_or_overwrite_stale) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * add_v,
int (*is_stale_cb) (BVT
(clib_bihash_kv)
*, void *),
void *arg);
int BV (clib_bihash_add_or_overwrite_stale) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * add_v,
int (*is_stale_cb) (BVT
(clib_bihash_kv)
*, void *),
void *arg);
+int BV (clib_bihash_add_with_overwrite_cb) (
+ BVT (clib_bihash) * h, BVT (clib_bihash_kv) * add_v,
+ void (*overwrite_cb) (BVT (clib_bihash_kv) *, void *), void *arg);
int BV (clib_bihash_search) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * search_v,
BVT (clib_bihash_kv) * return_v);
int BV (clib_bihash_search) (BVT (clib_bihash) * h,
BVT (clib_bihash_kv) * search_v,
BVT (clib_bihash_kv) * return_v);
+int BV (clib_bihash_is_initialised) (const BVT (clib_bihash) * h);
+
#define BIHASH_WALK_STOP 0
#define BIHASH_WALK_CONTINUE 1
#define BIHASH_WALK_STOP 0
#define BIHASH_WALK_CONTINUE 1
@@
-397,6
+410,7
@@
BV (clib_bihash_get_bucket) (BVT (clib_bihash) * h, u64 hash)
static inline int BV (clib_bihash_search_inline_with_hash)
(BVT (clib_bihash) * h, u64 hash, BVT (clib_bihash_kv) * key_result)
{
static inline int BV (clib_bihash_search_inline_with_hash)
(BVT (clib_bihash) * h, u64 hash, BVT (clib_bihash_kv) * key_result)
{
+ BVT (clib_bihash_kv) rv;
BVT (clib_bihash_value) * v;
BVT (clib_bihash_bucket) * b;
int i, limit;
BVT (clib_bihash_value) * v;
BVT (clib_bihash_bucket) * b;
int i, limit;
@@
-442,7
+456,10
@@
static inline int BV (clib_bihash_search_inline_with_hash)
{
if (BV (clib_bihash_key_compare) (v->kvp[i].key, key_result->key))
{
{
if (BV (clib_bihash_key_compare) (v->kvp[i].key, key_result->key))
{
- *key_result = v->kvp[i];
+ rv = v->kvp[i];
+ if (BV (clib_bihash_is_free) (&rv))
+ return -1;
+ *key_result = rv;
return 0;
}
}
return 0;
}
}
@@
-496,6
+513,7
@@
static inline int BV (clib_bihash_search_inline_2_with_hash)
(BVT (clib_bihash) * h,
u64 hash, BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
{
(BVT (clib_bihash) * h,
u64 hash, BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
{
+ BVT (clib_bihash_kv) rv;
BVT (clib_bihash_value) * v;
BVT (clib_bihash_bucket) * b;
int i, limit;
BVT (clib_bihash_value) * v;
BVT (clib_bihash_bucket) * b;
int i, limit;
@@
-543,7
+561,10
@@
static inline int BV (clib_bihash_search_inline_2_with_hash)
{
if (BV (clib_bihash_key_compare) (v->kvp[i].key, search_key->key))
{
{
if (BV (clib_bihash_key_compare) (v->kvp[i].key, search_key->key))
{
- *valuep = v->kvp[i];
+ rv = v->kvp[i];
+ if (BV (clib_bihash_is_free) (&rv))
+ return -1;
+ *valuep = rv;
return 0;
}
}
return 0;
}
}