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 94C3BA04DD; Tue, 20 Oct 2020 22:58:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A17FA902; Tue, 20 Oct 2020 22:58:18 +0200 (CEST) Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by dpdk.org (Postfix) with ESMTP id 8AD66A8F2 for ; Tue, 20 Oct 2020 22:58:16 +0200 (CEST) Received: by mail-pj1-f65.google.com with SMTP id hk7so1604004pjb.2 for ; Tue, 20 Oct 2020 13:58:16 -0700 (PDT) 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=tWtiScIgxhH1qyZaztNxzWoi9kWBm9p4bxI426lhqHQ=; b=DGyN7Q2r2mfmKLPkQQtEv7RtgLDeUQNcoLa/k96T5Zo0zeYfzparTac7Icx5VUVfYi YwCqbFIsUZ+gShhaiuYwzauVPwH76GZWcheq5N6SMIKC3MA45409ERlQmoZLvyxQbheL IqMeGXPGunctInDRv9iHWkwoMRWy6/n7GinevHpc4YD2Ee4LE7J66LKd9o56kv6zcsz/ 6EroYbogAnf684Gg1pciJpkr2dEHcb1KjEnC2AGzIbrVQPog6G+cnFeA1oJ0uHsGT4fI ei5rZr0MvhEVT6cnBJsbrsexT1Uq6iuPEt98SbhtmHMpVrxsGS4vdAUz4g/FrtMK0wXP byHA== 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=tWtiScIgxhH1qyZaztNxzWoi9kWBm9p4bxI426lhqHQ=; b=lqoGwNr4WOZFlasNGh9OT7no4GU8dRTKxVAjO/gdbhjBdSamOp4pw6UJdLRmOIW/zj 4mIz6zStRt4qfOV+AkScRPNhH2BX6ncOs/lzcqiopG+KYqJr9RAlBe+gH7P0TLcEygHv l4Mw8muq333X7tHjJcAHtuiyQGQP7h24OsYK/4l2FcsIsKbwJgwe7q8Bg43kke4QNVA0 2l+453y5jJYpF5t5a5oZDSELwiHQ4fVfXswj3MKcA8iEx6xQHhs/U+F1VGxZdPRITGGt XoyievFkYTMEtZ1yzLxUqZRdO6CtobgIz0rjg0ZPOK9k7WyspPz3xQDLaQFk7TNsF3BX GfSA== X-Gm-Message-State: AOAM531yF/aC9+n54J+j0EeUHSlzc48SjrMOraWD6WbKt1SkUkDsBOy+ xzblolx4v5YEF+xB/w7BHX2n6H6IrKLqng== X-Google-Smtp-Source: ABdhPJwgHv6nV3K5yP8KViMwe8p8bHBFzWIXJSqvrtHRWmM2DubUxcb5NKmu03X+4GaBXmVeUG7ZwA== X-Received: by 2002:a17:90b:3314:: with SMTP id kf20mr95686pjb.19.1603227494295; Tue, 20 Oct 2020 13:58:14 -0700 (PDT) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l82sm3268262pfd.102.2020.10.20.13.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 13:58:13 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: stable@dpdk.org, Stephen Hemminger , olivier.matz@6wind.com Date: Tue, 20 Oct 2020 13:58:05 -0700 Message-Id: <20201020205805.24311-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201015172019.3181-1-stephen@networkplumber.org> References: <20201015172019.3181-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] 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 --- v2 - move check to inside locked region lib/librte_mbuf/rte_mbuf_dyn.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c index 538a43f6959f..717898c0df02 100644 --- a/lib/librte_mbuf/rte_mbuf_dyn.c +++ b/lib/librte_mbuf/rte_mbuf_dyn.c @@ -185,13 +185,11 @@ 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) { @@ -384,13 +382,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