From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH] ethdev: report error on name truncation Date: Mon, 7 Jan 2019 07:53:32 -0800 Message-ID: <20190107075332.1301e617@hermes.lan> References: <20190107143951.30076-1-ndabilpuram@marvell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Nithin Kumar Dabilpuram , Thomas Monjalon , Ferruh Yigit , "dev@dpdk.org" , Jerin Jacob Kollanukkaran To: Andrew Rybchenko Return-path: Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id EFBE21B3EC for ; Mon, 7 Jan 2019 16:53:35 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id a14so316357plm.12 for ; Mon, 07 Jan 2019 07:53:35 -0800 (PST) In-Reply-To: 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 Mon, 7 Jan 2019 17:47:08 +0300 Andrew Rybchenko wrote: > On 1/7/19 5:40 PM, Nithin Kumar Dabilpuram wrote: > > Signed-off-by: Nithin Dabilpuram > > --- > > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > > index 9d5107d..bd45445 100644 > > --- a/lib/librte_ethdev/rte_ethdev.c > > +++ b/lib/librte_ethdev/rte_ethdev.c > > @@ -3588,9 +3588,17 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, > > { > > char z_name[RTE_MEMZONE_NAMESIZE]; > > const struct rte_memzone *mz; > > + int rc; > > > > - snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", > > - dev->data->port_id, queue_id, ring_name); > > + rc = snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", > > + dev->device->driver->name, ring_name, > > + dev->data->port_id, queue_id); > > + > > + if (rc >= RTE_MEMZONE_NAMESIZE) { > > + RTE_LOG(ERR, EAL, "%s(): truncated name\n", __func__); > > + rte_errno = ENAMETOOLONG; > > + return NULL; > > + } > > > > mz = rte_memzone_lookup(z_name); > > if (mz) > > It is good to report an error in the case of name truncation, but the patch > does more. It changes format of the memzone name, adds the driver name > in it (what is bad since testpmd has commands to find the memzone by name > and read descriptors (hack, but sometimes very useful)). > Also I'm not sure about function name in the log message. Other places > do not have it. > Maybe MEMZONE_NAMESIZE should be big enough that this should never happen? The size is arbitrary anyway.