From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: [PATCH v3] net/tap: fix dev name look-up Date: Mon, 6 Mar 2017 15:41:14 +0000 Message-ID: <2bbf94d7-7fe9-410d-438c-41a5560497c2@intel.com> References: <64e79c8c7398e0af093168d614c0ca62dc28377e.1488808159.git.pascal.mazon@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Pascal Mazon , keith.wiles@intel.com Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 65439914 for ; Mon, 6 Mar 2017 16:41:17 +0100 (CET) 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 3/6/2017 3:13 PM, Pascal Mazon wrote: > Store the device name in dev->data->name, to have symmetrical behavior > between rte_pmd_tap_probe(name) and rte_pmd_tap_remove(name). > > The netdevice name (linux interface name) is stored in the name field of > struct pmd_internals. > > snprintf(data->name) has been moved closer to the rte_ethdev_allocate() > as it should use the same name. > > Signed-off-by: Pascal Mazon > --- > drivers/net/tap/rte_eth_tap.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c > index 47a706070652..ece3a5fcc897 100644 > --- a/drivers/net/tap/rte_eth_tap.c > +++ b/drivers/net/tap/rte_eth_tap.c > @@ -663,7 +663,9 @@ eth_dev_tap_create(const char *name, char *tap_name) > goto error_exit; > } > > - dev = rte_eth_dev_allocate(tap_name); > + /* name in allocation and data->name must be consistent */ > + snprintf(data->name, sizeof(data->name), "%s", name); When you use correct name (name) for rte_eth_dev_allocate(), snprintf() no more required. rte_eth_dev_allocate() already does it [1]. [1] http://dpdk.org/browse/dpdk/tree/lib/librte_ether/rte_ethdev.c#n230 > + dev = rte_eth_dev_allocate(name); > if (!dev) { > RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n"); > goto error_exit; > @@ -691,7 +693,6 @@ eth_dev_tap_create(const char *name, char *tap_name) > dev->driver = NULL; > dev->rx_pkt_burst = pmd_rx_burst; > dev->tx_pkt_burst = pmd_tx_burst; > - snprintf(dev->data->name, sizeof(dev->data->name), "%s", name); > > /* Presetup the fds to -1 as being not valid */ > for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { >