The dynamic flag management is broken for multi-process environment.
All calls to lookup dynamic flags or fields will fail in secondary process.
This is because the local pointer to the memzone is not ever initialized.

Fix it by using the same checks as dynfield_register().
I.e if shared memory zone has not been looked up already,
then discover it.

Fixes: 4958ca3a443a ("mbuf: support dynamic fields and flags")
Cc: olivier.m...@6wind.com
Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 lib/librte_mbuf/rte_mbuf_dyn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c
index 538a43f6959f..ac4801b4d770 100644
--- a/lib/librte_mbuf/rte_mbuf_dyn.c
+++ b/lib/librte_mbuf/rte_mbuf_dyn.c
@@ -185,7 +185,7 @@ rte_mbuf_dynfield_lookup(const char *name, struct 
rte_mbuf_dynfield *params)
 {
        struct mbuf_dynfield_elt *mbuf_dynfield;
 
-       if (shm == NULL) {
+       if (shm == NULL && init_shared_mem() < 0) {
                rte_errno = ENOENT;
                return -1;
        }
@@ -384,7 +384,7 @@ rte_mbuf_dynflag_lookup(const char *name,
 {
        struct mbuf_dynflag_elt *mbuf_dynflag;
 
-       if (shm == NULL) {
+       if (shm == NULL && init_shared_mem() < 0) {
                rte_errno = ENOENT;
                return -1;
        }
-- 
2.27.0

Reply via email to