From: Stephen Hemminger Date: Wed, 4 Nov 2020 16:20:00 +0000 (-0800) Subject: mbuf: fix dynamic fields and flags with multiprocess X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0429a2e1a445a424b2982f3ce4b3fb34a7d1b796;p=dpdk.git mbuf: fix dynamic fields and flags with multiprocess The dynamic flag management is broken if rte_mbuf_dynflag_lookup() is done in a secondary process 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: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Olivier Matz --- diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c index e10f4fb125..fd3e019a22 100644 --- a/lib/librte_mbuf/rte_mbuf_dyn.c +++ b/lib/librte_mbuf/rte_mbuf_dyn.c @@ -174,7 +174,7 @@ __mbuf_dynfield_lookup(const char *name) break; } - if (te == NULL) { + if (te == NULL || mbuf_dynfield == NULL) { rte_errno = ENOENT; return NULL; } @@ -187,19 +187,15 @@ rte_mbuf_dynfield_lookup(const char *name, struct rte_mbuf_dynfield *params) { struct mbuf_dynfield_elt *mbuf_dynfield; - if (shm == NULL) { - rte_errno = ENOENT; - return -1; - } - rte_mcfg_tailq_read_lock(); - mbuf_dynfield = __mbuf_dynfield_lookup(name); + if (shm == NULL && init_shared_mem() < 0) + mbuf_dynfield = NULL; + else + mbuf_dynfield = __mbuf_dynfield_lookup(name); rte_mcfg_tailq_read_unlock(); - if (mbuf_dynfield == NULL) { - rte_errno = ENOENT; + if (mbuf_dynfield == NULL) return -1; - } if (params != NULL) memcpy(params, &mbuf_dynfield->params, sizeof(*params)); @@ -386,19 +382,15 @@ rte_mbuf_dynflag_lookup(const char *name, { struct mbuf_dynflag_elt *mbuf_dynflag; - if (shm == NULL) { - rte_errno = ENOENT; - return -1; - } - rte_mcfg_tailq_read_lock(); - mbuf_dynflag = __mbuf_dynflag_lookup(name); + if (shm == NULL && init_shared_mem() < 0) + mbuf_dynflag = NULL; + else + mbuf_dynflag = __mbuf_dynflag_lookup(name); rte_mcfg_tailq_read_unlock(); - if (mbuf_dynflag == NULL) { - rte_errno = ENOENT; + if (mbuf_dynflag == NULL) return -1; - } if (params != NULL) memcpy(params, &mbuf_dynflag->params, sizeof(*params));