From f328c15d04453bf8d78fe96a0545778bf5af5c28 Mon Sep 17 00:00:00 2001 From: roykingz Date: Wed, 6 Sep 2023 16:13:24 +0800 Subject: [PATCH 1/3] dpvs: no need to set memory allocated by rte_zmalloc to zero --- include/parser/utils.h | 2 -- src/iftraf.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/include/parser/utils.h b/include/parser/utils.h index 0ea27f1a5..7f65f6ef6 100644 --- a/include/parser/utils.h +++ b/include/parser/utils.h @@ -31,8 +31,6 @@ static inline void* xmalloc(uint32_t sz) { void *mem = rte_zmalloc("cfgfile", sz, RTE_CACHE_LINE_SIZE); - if (mem) - memset(mem, 0, sz); return mem; } diff --git a/src/iftraf.c b/src/iftraf.c index a03277402..c760822f2 100644 --- a/src/iftraf.c +++ b/src/iftraf.c @@ -477,7 +477,6 @@ static void inline iftraf_tlb_add(struct iftraf_pkt *param) return; } - memset(entry, 0, sizeof(struct iftraf_entry)); entry->af = param->af; entry->cid = param->cid; entry->devid = param->devid; @@ -578,7 +577,6 @@ static void inline iftraf_iftlb_add(struct iftraf_pkt *param) return; } - memset(entry, 0, sizeof(struct iftraf_entry)); entry->af = param->af; entry->cid = param->cid; entry->devid = param->devid; From 33c9f4356e36e7707c592a1c275aabcd6efea55f Mon Sep 17 00:00:00 2001 From: roykingz Date: Wed, 6 Sep 2023 16:37:54 +0800 Subject: [PATCH 2/3] dpvs: fix ipv4 pkts stats bug --- include/ipv4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ipv4.h b/include/ipv4.h index cf95882f2..394272bbb 100644 --- a/include/ipv4.h +++ b/include/ipv4.h @@ -100,7 +100,7 @@ extern rte_spinlock_t ip4_stats_lock; #define IP4_UPD_PO_STATS(field, val) \ do { \ rte_spinlock_lock(&ip4_stats_lock); \ - __IP4_ADD_STATS(field##pkts, (val)); \ + __IP4_ADD_STATS(field##pkts, (1)); \ __IP4_ADD_STATS(field##octets, (val)); \ rte_spinlock_unlock(&ip4_stats_lock); \ } while (0) From d02d711887146f0b746603812aa82270a7cda4f5 Mon Sep 17 00:00:00 2001 From: roykingz Date: Tue, 12 Sep 2023 10:02:29 +0800 Subject: [PATCH 3/3] dpvs: fix all cfgfile parser malloc problems --- src/parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser.c b/src/parser.c index 6ac4313e2..11491f7eb 100644 --- a/src/parser.c +++ b/src/parser.c @@ -392,9 +392,9 @@ void *set_value(vector_t tokens) str = VECTOR_SLOT(tokens, i); len += strlen(str); if (!alloc) - alloc = (char *) MALLOC(sizeof(char *) * (len + 1)); + alloc = (char *) MALLOC(sizeof(char) * (len + 1)); else { - alloc = REALLOC(alloc, sizeof(char *) * (len + 1)); + alloc = REALLOC(alloc, sizeof(char) * (len + 1)); tmp = VECTOR_SLOT(tokens, i - 1); if ( *str != '"' && *tmp != '"') strncat(alloc, " ", 1);