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 C9D05A04E7; Wed, 4 Nov 2020 06:53:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3AC02BE71; Wed, 4 Nov 2020 06:53:24 +0100 (CET) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 6DD20BE63 for ; Wed, 4 Nov 2020 06:53:21 +0100 (CET) Received: by mail-pf1-f196.google.com with SMTP id 133so16385431pfx.11 for ; Tue, 03 Nov 2020 21:53:21 -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=I1ICd0uIcay7Axeo3k4+MwQjlTvclq4rUSwrMMR+DH8=; b=NQqTUNGwy2PPmA57eoQ6qstqzq38z+MBV6YCjEtNZLWX9LGLFUADhVe4DvzpOw3lXM XsNxSCrkdYiX5Ny/COf87ns2j+b7DgQqfDI2uVfcUreL2E26IP+BThBfUea6OQyVFUro R0X+FmlSFbxsEcI8pUdLWDx5eX/QVOi0d6ZHLaV0lvI3YKcShF9/Cqs16hskeTbFrC+/ 26RleyBuqTx+UNkWWAMZ4iZsU2n3sVpqDeg5mgei7YUMGMpSPmB5N5eTkebUrLy0o7jC 8XIEdf2Ei5M88gi7QUSFQURtQzxWYyaXPKPfqfKbaavz5QP4QSkLV/vM1hp3qpZ+GoHS GnJw== 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=I1ICd0uIcay7Axeo3k4+MwQjlTvclq4rUSwrMMR+DH8=; b=R/tBRSOF4tSGVlhH/yBl+daU8pnJ4QiympkMMX99DOeg9LB/zKLbZfgotR5QP3B+du mkt/809zSPazlm0lT3ctH1ffDDyQsxyMCb/xkLpRh1RzPEQP6Dc+A38gMBikqGLM1SLk /ykbLHV4UzblcBDctzVgX7XTT8fisuPznwYLVHZ1pWxI3s06ax0Cw3M73+JFW5qsvlev 3DkiC8OjlUHa89imY4Zh9i3djBI1q9IQpt3SoATSRWwHrN9dsUpv+N1L/MkB2v+ISDm9 4YtPNMS37tgZEf2+vZgOBwnLN0O2rrEvruzsUO4cK8qj7Sc7O4fZv9BCC7Ktr10QZCYs D/9Q== X-Gm-Message-State: AOAM533F3/GWLZB3ImpSRVTloUMhnueKJpuVwqf72nuAAfg5z7hIYbIv mCdXywvkBMBJRvDPW3/jA+6luXQyvR1a4Jk4 X-Google-Smtp-Source: ABdhPJyaO43pSatbetFyfS9bLpUAaLc9EBRPwNyBRihbvuIOGPbC1IRg/wplfDqDYdnNE/QGCYlAfw== X-Received: by 2002:a17:90b:698:: with SMTP id m24mr2901172pjz.154.1604469198902; Tue, 03 Nov 2020 21:53:18 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id v24sm793772pgi.91.2020.11.03.21.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 21:53:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Tue, 3 Nov 2020 21:53:10 -0800 Message-Id: <20201104055310.18873-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 v4] 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 --- v4 - incorporate Oliver's fix for rte_errno lib/librte_mbuf/rte_mbuf_dyn.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c index 538a43f6959f..b4c31896634c 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,13 +380,11 @@ 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) { -- 2.27.0