hash: check flags on creation for future proofing
All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
This commit is contained in:
parent
3e71b3d456
commit
0cc917d809
@ -32,6 +32,14 @@
|
||||
#include "rte_hash.h"
|
||||
#include "rte_cuckoo_hash.h"
|
||||
|
||||
/* Mask of all flags supported by this version */
|
||||
#define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \
|
||||
RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \
|
||||
RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \
|
||||
RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \
|
||||
RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \
|
||||
RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)
|
||||
|
||||
#define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET) \
|
||||
for (CURRENT_BKT = START_BUCKET; \
|
||||
CURRENT_BKT != NULL; \
|
||||
@ -164,6 +172,12 @@ rte_hash_create(const struct rte_hash_parameters *params)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) {
|
||||
rte_errno = EINVAL;
|
||||
RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Validate correct usage of extra options */
|
||||
if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
|
||||
(params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
|
||||
|
Loading…
Reference in New Issue
Block a user