net/tap: fix dev name look-up

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.

Fixes: 02f96a0a82d1 ("net/tap: add TUN/TAP device PMD")

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
Acked-by: Keith Wiles <keith.wiles@intel.com>
This commit is contained in:
Pascal Mazon 2017-03-06 16:13:08 +01:00 committed by Ferruh Yigit
parent 676d11ffb2
commit 66db3932dd

View File

@ -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);
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++) {