From 44a74ac537fbee031bedda74fa05099f3fd3f552 Mon Sep 17 00:00:00 2001 From: Isaac Boukris Date: Sun, 5 Feb 2023 11:20:29 +0200 Subject: [PATCH] Demo bug in rte_hash_lookup --- examples/helloworld/Makefile | 2 +- examples/helloworld/main.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile index 2a6a2f1527..14e44b8aa8 100644 --- a/examples/helloworld/Makefile +++ b/examples/helloworld/Makefile @@ -22,7 +22,7 @@ static: build/$(APP)-static ln -sf $(APP)-static build/$(APP) PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) -CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) +CFLAGS += -O0 -fsanitize=address $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c index af509138da..7460fbdfea 100644 --- a/examples/helloworld/main.c +++ b/examples/helloworld/main.c @@ -15,6 +15,11 @@ #include #include +#include +#include +#include +#include + /* Launch a function on lcore. 8< */ static int lcore_hello(__rte_unused void *arg) @@ -26,18 +31,36 @@ lcore_hello(__rte_unused void *arg) } /* >8 End of launching function on lcore. */ +static char hash_key[10] = ""; + +static struct rte_hash_parameters h_params = { + .entries = 64, + .key_len = sizeof(hash_key), + .hash_func = rte_jhash, + .hash_func_init_val = 0, + .socket_id = 0, +}; + /* Initialization of Environment Abstraction Layer (EAL). 8< */ int main(int argc, char **argv) { int ret; unsigned lcore_id; + struct rte_hash *handle; + int pos; ret = rte_eal_init(argc, argv); if (ret < 0) rte_panic("Cannot init EAL\n"); /* >8 End of initialization of Environment Abstraction Layer */ + handle = rte_hash_create(&h_params); + assert(handle != NULL); + + pos = rte_hash_lookup(handle, &hash_key); + assert(pos == -ENOENT); + /* Launches the function on each lcore. 8< */ RTE_LCORE_FOREACH_WORKER(lcore_id) { /* Simpler equivalent. 8< */ -- 2.31.1