Re: [dpdk-dev] [PATCH v4] mbuf: fix reset on mbuf free
From: Morten Brørup <hidden>
Date: 2021-06-15 13:56:11
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Matz Sent: Wednesday, 13 January 2021 14.28
[snip]
Fixes: 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool")
Cc: stable@dpdk.org
Signed-off-by: Olivier Matz <redacted>
Acked-by: Morten Brørup <redacted>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Konstantin Ananyev <redacted>
---
v4
* add a unit test (suggested by David)
v3
* fix commit log again (thanks Morten for spotting it)
v2
* avoid write access if uneeded (suggested by Konstantin)
* enhance comments in mbuf header file (suggested by Morten)
* fix commit log
app/test/test_mbuf.c | 69 +++++++++++++++++++++++++++++++++
lib/librte_mbuf/rte_mbuf.c | 4 +-
lib/librte_mbuf/rte_mbuf.h | 8 ++--
lib/librte_mbuf/rte_mbuf_core.h | 13 ++++++-
4 files changed, 86 insertions(+), 8 deletions(-)[snip]
quoted hunk ↗ jump to hunk
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 7d09ee2939..5f77840557 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c@@ -129,10 +129,10 @@ rte_pktmbuf_free_pinned_extmem(void *addr, void*opaque) rte_mbuf_ext_refcnt_set(m->shinfo, 1); m->ol_flags = EXT_ATTACHED_MBUF; - if (m->next != NULL) { + if (m->next != NULL) m->next = NULL; + if (m->nb_segs != 1) m->nb_segs = 1; - } rte_mbuf_raw_free(m); }diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index c4c9ebfaa0..8c1097ed76 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h@@ -1340,10 +1340,10 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) return NULL; } - if (m->next != NULL) { + if (m->next != NULL) m->next = NULL; + if (m->nb_segs != 1) m->nb_segs = 1; - } return m;@@ -1357,10 +1357,10 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) return NULL; } - if (m->next != NULL) { + if (m->next != NULL) m->next = NULL; + if (m->nb_segs != 1) m->nb_segs = 1; - } rte_mbuf_refcnt_set(m, 1); return m;
Olivier, have you considered if Konstantin's suggestion (to avoid write access if unneeded) could be applied to any of the other functions in rte_mbuf.h, e.g. __rte_pktmbuf_free_direct()?