From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 392E8A0C47; Tue, 12 Oct 2021 09:49:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BCA6340142; Tue, 12 Oct 2021 09:49:55 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id CD7134003C for ; Tue, 12 Oct 2021 09:49:53 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 4D5437F50A; Tue, 12 Oct 2021 10:49:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 4D5437F50A DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634024993; bh=61JcsGdSQ+cKMoTC+8wmXqc9XHCmjWNDfmfHTyFKdXM=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=OytZwJLWlx9Yz5owYWOvN+zvPWyMXKbD24YbxR7B4vwZMwR8taya0aIQhyVd8IL89 RaKPF8IoV4Licz7+VqeYPtbUNZR960hWgHv20bKbbjG/4U77i9+t7w8pvHj9zmcYFD pMdSSxnsqbSp5evzVlCpgGwnaYy8dLHiEvmrEmzg= To: David Marchand , dev@dpdk.org Cc: mdr@ashroe.eu, dkozlyuk@oss.nvidia.com, thomas@monjalon.net, Olivier Matz References: <20211012072848.17741-1-david.marchand@redhat.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: Date: Tue, 12 Oct 2021 10:49:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211012072848.17741-1-david.marchand@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] mempool: enforce valid flags at creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 10/12/21 10:28 AM, David Marchand wrote: > If we do not enforce valid flags are passed by an application, this > application might face issues in the future when we add more flags. Thanks. I'd even consider it as a bug and the fix to be backported. > > Signed-off-by: David Marchand A nit below, other than that: Reviewed-by: Andrew Rybchenko [snip] > diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c > index c5f859ae71..a2a78125f4 100644 > --- a/lib/mempool/rte_mempool.c > +++ b/lib/mempool/rte_mempool.c > @@ -777,6 +777,13 @@ rte_mempool_cache_free(struct rte_mempool_cache *cache) > rte_free(cache); > } > > +#define MEMPOOL_KNOWN_FLAGS ( MEMPOOL_F_NO_SPREAD \ > + | MEMPOOL_F_NO_CACHE_ALIGN \ > + | MEMPOOL_F_SP_PUT \ > + | MEMPOOL_F_SC_GET \ > + | MEMPOOL_F_POOL_CREATED \ > + | MEMPOOL_F_NO_IOVA_CONTIG \ > + ) > /* create an empty mempool */ > struct rte_mempool * > rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, > @@ -806,6 +813,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, > RTE_CACHE_LINE_MASK) != 0); > #endif > > + /* enforce no unknown flag is passed by the application */ > + if ((flags & ~MEMPOOL_KNOWN_FLAGS) != 0) { > + rte_errno = EINVAL; > + return NULL; > + } > + I think it is better to check arguments in parameters order. So, it is a bit better to move the check to happen after cache_size validation below. > mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list); > > /* asked for zero items */ [snip]