From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C93CA04B1; Wed, 4 Nov 2020 17:20:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 393273772; Wed, 4 Nov 2020 17:20:14 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 9239D3421 for ; Wed, 4 Nov 2020 17:20:12 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id b3so17709531pfo.2 for ; Wed, 04 Nov 2020 08:20:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AmycSGn99cV8GPWtLmQFnotNhRXpFTNkhTdlkbK/NT0=; b=SoKcFCtq3AFpcyFdM2wP1KSOoe7jliXR9F1VDn7LqUoAYpNdCTjBhoy06NWhVHYluQ +Tvq0D14mELYeBA6AvGH2Cj30v4vi9K2m13ScFvUgmaIJTe0f4/eVhB3FuiIRvOVj8N9 A7Gpyw38kE3osPKMD2XXdEl5Bva3RW8Syv/08PijZS47KpQcnRFdrdgxY3IpJRpnrKvr pDX7d+ndB7aO9JA2gwVTrYlWMO49taQYkn9p2hO39fmYR9xAkL6Rd9fPJ/fHogoraTBB 6pK1tuTMXSI9LVWSJITd6cqofuga1EmppYRne59SlDchPO84wmcwu9vHSzjo9s/SFp5l S6NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AmycSGn99cV8GPWtLmQFnotNhRXpFTNkhTdlkbK/NT0=; b=J9AoS68aK1NcMmhIcZq7ouiiGjhUD2MxmfoHshs+Id9mEKwdKL0axlwayJHXQh7F6l Kpgfgwytm2b6NaofrNB/9Vq++c7997Wf/s/qnjnyhCz4xKdG1ocg2R2IAj+U2aOOoiat +E0E5ZspDpZ0lV3vYWiFu98h+nzKefL9CYCTeMR4f5FXsw+FxQcL/nmztT+YwShJpfOX F1bhHbtrfNKAzSBpvWTL8ohqX5Yfbes1AEsyMfVeMlEbs94+KWXT9sEKVws49C1bOLTY LaiAY50EVdlmMZZmRGur2GrQaG/7gw4SLi5kGT6GNICRV4OUeol7QZJaURBIkzp+kx56 umIA== X-Gm-Message-State: AOAM530VnoxI7WzVoUJKpxKFIG9d1Sg6gcFXUhELbuto6JYWuUr5UJid ytXYpLmr3caIfFXoVSu9ZJn/NB2LecDp+gU/ X-Google-Smtp-Source: ABdhPJzExSPfldL17emd+hRwvXK9f9a7IgNh0EV7uvpiF+9wbkuYShluGBiNRhdssIJ1FmKUqf1wsw== X-Received: by 2002:a17:90a:c917:: with SMTP id v23mr4853793pjt.235.1604506810121; Wed, 04 Nov 2020 08:20:10 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id f17sm2935403pfq.141.2020.11.04.08.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 08:20:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Wed, 4 Nov 2020 08:20:00 -0800 Message-Id: <20201104162000.9419-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201024004331.25043-1-stephen@networkplumber.org> References: <20201024004331.25043-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5] mbuf: allow dynamic flags to be used by secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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: olivier.matz@6wind.com Signed-off-by: Stephen Hemminger --- v5 - fix additional rte_errno overwrite lib/librte_mbuf/rte_mbuf_dyn.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c index 538a43f6959f..c2f7220e7ba3 100644 --- a/lib/librte_mbuf/rte_mbuf_dyn.c +++ b/lib/librte_mbuf/rte_mbuf_dyn.c @@ -172,7 +172,7 @@ __mbuf_dynfield_lookup(const char *name) break; } - if (te == NULL) { + if (te == NULL || mbuf_dynfield == NULL) { rte_errno = ENOENT; return NULL; } @@ -185,19 +185,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)); @@ -384,19 +380,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)); -- 2.27.0