From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RVFPRFXghZl3lUuIY3b2SvXgu4B07YdszE71fVzMcH8=; b=C+sYiQVA/e5ubmR3DGXSam7lI20Llx2YQ5Dx4C76k/DbOeviv47CfsgwJ6bm1jGPE+ ISyMZvROWYFbnz9iJEuBSjz96SG2a01T1cKIalmfslA70fWZ2VYTO0+s70VNl8KtGZL0 7lDEfwFfXNodAKa+C9WEBhUDbgnttSD4d7mi5Dv8iAYRwR9Lncrp+gKzkbURTTovqzqo No7VyIxS+yGGcG4D7iAaqbVk5WKddfuOYnuF8SPNhZF5htZLwhCSzcnT8YoAhURbAw96 k9rBtL6ggxIHIto72AMa8Q6lFoFudT+QQDR8TkrP7VNNwOH4BHjWCeFBzKcpzcE5f809 /+mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RVFPRFXghZl3lUuIY3b2SvXgu4B07YdszE71fVzMcH8=; b=tPifYj6jxTZseYpsJYpbxEqxMpIgx9FWpbJWsl9SDQVfoFuyoUcxAk/i8kyQkOLL25 aw+CL+YISCA8yDzJYdEZ2hkiiEirX6SsP1j9DbCmNID5qDxeAm9w11cUF2k/mLNKe48M kf+F4Fkf8vksX1zDkylRH9NFyby7DCFfk6iZQ9qMaFhPuCyPdEzhqZSjU87YP1DcMcTQ h2f356dkg5zXHRqTv+osNoTe0wYr1Uk+jMlmZ5XlpeUSHxkoBIMztbf5S3xMmfoYAyYJ 21AScUR8nUX2rVl5yAwsm8do4Vg3rNxxL+BMS1S85mFeGHX0fZQPC4x4anq1y+UA5O52 LJog== X-Gm-Message-State: AJcUukdXZ8pw5z4tCEum2P9o+k7QDwueH8n05t/8BXilAH3h/S9UwiCg VTua/i1ECEXFe/mb6WcQ3OwslU2cr08= X-Google-Smtp-Source: ALg8bN67BjQZBhp/CiAQfmRcsW/ovk+bmCs3IiGr9f8lOuKxFlnPkxNL2BIWonQ7vAjvpPBRnfpsKQ== X-Received: by 2002:a17:902:714c:: with SMTP id u12mr60990762plm.234.1546876415086; Mon, 07 Jan 2019 07:53:35 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d18sm102016657pfj.47.2019.01.07.07.53.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:53:34 -0800 (PST) Date: Mon, 7 Jan 2019 07:53:32 -0800 From: Stephen Hemminger To: Andrew Rybchenko Cc: Nithin Kumar Dabilpuram , Thomas Monjalon , Ferruh Yigit , "dev@dpdk.org" , Jerin Jacob Kollanukkaran Message-ID: <20190107075332.1301e617@hermes.lan> In-Reply-To: References: <20190107143951.30076-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] ethdev: report error on name truncation 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: , X-List-Received-Date: Mon, 07 Jan 2019 15:53:36 -0000 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.