summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/handle_gen.c
diff options
context:
space:
mode:
authorXavier Simonart <xavier.simonart@intel.com>2020-05-29 23:15:04 +0200
committerXavier Simonart <xavier.simonart@intel.com>2020-05-29 23:52:44 +0200
commitbbeee9bd1c845d06518fd8fab590de5490d460a2 (patch)
tree6aa6bb8233c5e96a28ba716ce9d1ac8d029e50f9 /VNFs/DPPD-PROX/handle_gen.c
parent33d5f47e781c6986232378b7f8cadd17ac8894fe (diff)
Fix compilation issues on old DPDK
Also fixed minor issues such as - prevent using vdev on DPDK <= 17.05 as not supported - potential segmentation fault after panic (if panic thrown early in prox initialization) Change-Id: I49a1962e95a4a44dddadd1fdd906e1b3b232465c Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/handle_gen.c')
-rw-r--r--VNFs/DPPD-PROX/handle_gen.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/VNFs/DPPD-PROX/handle_gen.c b/VNFs/DPPD-PROX/handle_gen.c
index 7a004087..adcabd79 100644
--- a/VNFs/DPPD-PROX/handle_gen.c
+++ b/VNFs/DPPD-PROX/handle_gen.c
@@ -614,9 +614,16 @@ static int task_gen_reallocate_templates(struct task_gen *task, uint32_t nb_pkts
}
size_t mem_size = nb_pkts * sizeof(*task->pkt_template);
+ size_t old_mem_size = task->n_pkts * sizeof(*task->pkt_template);
+ if (old_mem_size > mem_size)
+ old_mem_size = mem_size;
+
struct pkt_template *ptr;
+
// re-allocate memory for new pkt_template (this might allocate additional memory or free up some...)
- if ((ptr = rte_realloc_socket(task->pkt_template, mem_size, RTE_CACHE_LINE_SIZE, task->socket_id)) != NULL) {
+ if ((ptr = rte_malloc_socket(NULL, mem_size, RTE_CACHE_LINE_SIZE, task->socket_id)) != NULL) {
+ memcpy(ptr, task->pkt_template, old_mem_size);
+ rte_free(task->pkt_template);
task->pkt_template = ptr;
} else {
plog_err_or_panic(do_panic, "Failed to allocate %lu bytes (in huge pages) for packet template for IMIX\n", mem_size);