From 13389617efbcb463caeca5d6209655b76ba87abe Mon Sep 17 00:00:00 2001 From: Luc Provoost Date: Sun, 8 Jan 2023 10:27:45 +0100 Subject: [PATCH] Fix socket_id in rte_hash_parameters The socket_id was either not initialized or set to 0. This fix sets the proper socket_id to the relevant NUMA node. When running on NUMA nodes other than 0, memory allocation for the hash table could fail. With this fix, it is supposed to work on all NUMA nodes. Signed-off-by: Luc Provoost Change-Id: I59887fe064a7e7c96ce2f6ce1c70791844b165b2 --- VNFs/DPPD-PROX/handle_cgnat.c | 1 + VNFs/DPPD-PROX/handle_gen.c | 1 + VNFs/DPPD-PROX/handle_master.c | 1 + VNFs/DPPD-PROX/handle_nat.c | 1 + VNFs/DPPD-PROX/packet_utils.c | 1 + VNFs/DPPD-PROX/prox_shared.c | 1 + 6 files changed, 6 insertions(+) diff --git a/VNFs/DPPD-PROX/handle_cgnat.c b/VNFs/DPPD-PROX/handle_cgnat.c index 03ea6dc8..9ce63b20 100644 --- a/VNFs/DPPD-PROX/handle_cgnat.c +++ b/VNFs/DPPD-PROX/handle_cgnat.c @@ -797,6 +797,7 @@ static int lua_to_hash_nat(struct task_args *targ, struct lua_State *L, enum lua .key_len = sizeof(struct private_key), .hash_func = rte_hash_crc, .hash_func_init_val = 0, + .socket_id = socket, }; plogx_info("hash table name = %s\n", hash_params.name); struct private_key private_key; diff --git a/VNFs/DPPD-PROX/handle_gen.c b/VNFs/DPPD-PROX/handle_gen.c index 23112251..2c8a65c7 100644 --- a/VNFs/DPPD-PROX/handle_gen.c +++ b/VNFs/DPPD-PROX/handle_gen.c @@ -1906,6 +1906,7 @@ static void init_task_gen(struct task_base *tbase, struct task_args *targ) .key_len = sizeof(union ipv4_5tuple_host), .hash_func = rte_hash_crc, .hash_func_init_val = 0, + .socket_id = task->socket_id, }; plog_info("\t\thash table name = %s\n", hash_params.name); task->flow_id_table = rte_hash_create(&hash_params); diff --git a/VNFs/DPPD-PROX/handle_master.c b/VNFs/DPPD-PROX/handle_master.c index a1c10d50..58240ba0 100644 --- a/VNFs/DPPD-PROX/handle_master.c +++ b/VNFs/DPPD-PROX/handle_master.c @@ -909,6 +909,7 @@ void init_ctrl_plane(struct task_base *tbase) .entries = n_entries, .hash_func = rte_hash_crc, .hash_func_init_val = 0, + .socket_id = socket_id, }; if (prox_cfg.flags & DSF_L3_ENABLED) { hash_params.key_len = sizeof(uint32_t); diff --git a/VNFs/DPPD-PROX/handle_nat.c b/VNFs/DPPD-PROX/handle_nat.c index 93559143..ad0fcf45 100644 --- a/VNFs/DPPD-PROX/handle_nat.c +++ b/VNFs/DPPD-PROX/handle_nat.c @@ -123,6 +123,7 @@ static int lua_to_hash_nat(struct lua_State *L, enum lua_place from, const char .key_len = sizeof(ip_from), .hash_func = rte_hash_crc, .hash_func_init_val = 0, + .socket_id = socket, }; ret_hash = rte_hash_create(&hash_params); diff --git a/VNFs/DPPD-PROX/packet_utils.c b/VNFs/DPPD-PROX/packet_utils.c index 0189a1e0..95ce7abc 100644 --- a/VNFs/DPPD-PROX/packet_utils.c +++ b/VNFs/DPPD-PROX/packet_utils.c @@ -492,6 +492,7 @@ void task_init_l3(struct task_base *tbase, struct task_args *targ) .key_len = sizeof(uint32_t), .hash_func = rte_hash_crc, .hash_func_init_val = 0, + .socket_id = socket_id, }; if (targ->flags & TASK_ARG_L3) { plog_info("\t\tInitializing L3 (IPv4)\n"); diff --git a/VNFs/DPPD-PROX/prox_shared.c b/VNFs/DPPD-PROX/prox_shared.c index 52f4eb18..de26441d 100644 --- a/VNFs/DPPD-PROX/prox_shared.c +++ b/VNFs/DPPD-PROX/prox_shared.c @@ -55,6 +55,7 @@ static void prox_sh_create_hash(struct prox_shared *ps, size_t size) { param.entries = size; param.name = get_sh_name(); + param.socket_id = rte_socket_id(); ps->hash = rte_hash_create(¶m); PROX_PANIC(ps->hash == NULL, "Failed to create hash table for shared data"); ps->size = size; -- 2.16.6