From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 6/6] net/tap: get rid of global tuntap_name
Date: Fri, 11 Jan 2019 10:06:59 -0800 [thread overview]
Message-ID: <20190111180659.5972-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20190111180659.5972-1-stephen@networkplumber.org>
Having a global variable which is set to "TUN" or "TAP" during
probe is a potential bug if probing is ever done in different
processes or contexts. Let's fix it now by using existing enum
that has type of connection.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index b836c1ae3d4e..0069930819c2 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -79,8 +79,6 @@ static const char *valid_arguments[] = {
NULL
};
-static char tuntap_name[8];
-
static volatile uint32_t tap_trigger; /* Rx trigger */
static struct rte_eth_link pmd_link = {
@@ -150,18 +148,17 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
fd = open(TUN_TAP_DEV_PATH, O_RDWR);
if (fd < 0) {
- TAP_LOG(ERR, "Unable to create %s interface", tuntap_name);
+ TAP_LOG(ERR, "Unable to open %s interface", TUN_TAP_DEV_PATH);
goto error;
}
#ifdef IFF_MULTI_QUEUE
/* Grab the TUN features to verify we can work multi-queue */
if (ioctl(fd, TUNGETFEATURES, &features) < 0) {
- TAP_LOG(ERR, "%s unable to get TUN/TAP features",
- tuntap_name);
+ TAP_LOG(ERR, "unable to get TUN/TAP features");
goto error;
}
- TAP_LOG(DEBUG, "%s Features %08x", tuntap_name, features);
+ TAP_LOG(DEBUG, "%s Features %08x", TUN_TAP_DEV_PATH, features);
if (features & IFF_MULTI_QUEUE) {
TAP_LOG(DEBUG, " Multi-queue support for %d queues",
@@ -1668,8 +1665,12 @@ static const struct eth_dev_ops ops = {
.filter_ctrl = tap_dev_filter_ctrl,
};
+static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
+ "UNKNOWN", "TUN", "TAP"
+};
+
static int
-eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
+eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
char *remote_iface, struct ether_addr *mac_addr,
enum rte_tuntap_type type)
{
@@ -1677,12 +1678,12 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
struct rte_eth_dev *dev;
struct pmd_internals *pmd;
struct pmd_process_private *process_private;
+ const char *tuntap_name = tuntap_types[type];
struct rte_eth_dev_data *data;
struct ifreq ifr;
int i;
- TAP_LOG(DEBUG, "%s device on numa %u",
- tuntap_name, rte_socket_id());
+ TAP_LOG(DEBUG, "%s device on numa %u", tuntap_name, rte_socket_id());
dev = rte_eth_vdev_allocate(vdev, sizeof(*pmd));
if (!dev) {
@@ -2015,8 +2016,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
char remote_iface[RTE_ETH_NAME_MAX_LEN];
struct rte_eth_dev *eth_dev;
- strcpy(tuntap_name, "TUN");
-
name = rte_vdev_device_name(dev);
params = rte_vdev_device_args(dev);
memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
@@ -2181,8 +2180,6 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
struct rte_eth_dev *eth_dev;
int tap_devices_count_increased = 0;
- strcpy(tuntap_name, "TAP");
-
name = rte_vdev_device_name(dev);
params = rte_vdev_device_args(dev);
@@ -2264,8 +2261,8 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
if (!tap_devices_count) {
ret = rte_mp_action_register(TAP_MP_KEY, tap_mp_sync_queues);
if (ret < 0) {
- TAP_LOG(ERR, "%s: Failed to register IPC callback: %s",
- tuntap_name, strerror(rte_errno));
+ TAP_LOG(ERR, "tap: Failed to register IPC callback: %s",
+ strerror(rte_errno));
goto leave;
}
}
@@ -2314,8 +2311,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
process_private = eth_dev->process_private;
TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u",
- (internals->type == ETH_TUNTAP_TYPE_TAP) ? "TAP" : "TUN",
- rte_socket_id());
+ tuntap_types[internals->type], rte_socket_id());
if (internals->nlsk_fd) {
tap_flow_flush(eth_dev, NULL);
--
2.20.1
next prev parent reply other threads:[~2019-01-11 18:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 18:06 [dpdk-dev] [PATCH 0/6] net/tap: fixes and cleanups Stephen Hemminger
2019-01-11 18:06 ` [dpdk-dev] [PATCH 1/6] net/tap: use strlcpy for interface name Stephen Hemminger
2019-01-11 18:06 ` [dpdk-dev] [PATCH 2/6] net/tap: allow full length names Stephen Hemminger
2019-01-11 19:32 ` Wiles, Keith
2019-01-11 19:48 ` Stephen Hemminger
2019-01-11 19:49 ` Wiles, Keith
2019-01-11 18:06 ` [dpdk-dev] [PATCH 3/6] net/tap: check interface name in kvargs Stephen Hemminger
2019-01-11 19:37 ` Wiles, Keith
2019-01-11 19:49 ` Stephen Hemminger
2019-01-11 19:50 ` Wiles, Keith
2019-01-15 2:01 ` Thomas Monjalon
2019-01-11 22:20 ` Luse, Paul E
2019-01-11 18:06 ` [dpdk-dev] [PATCH 4/6] net/tap: lower the priority of log messages Stephen Hemminger
2019-01-11 18:06 ` [dpdk-dev] [PATCH 5/6] net/tap: let kernel choose tun device name Stephen Hemminger
2019-01-11 19:43 ` Wiles, Keith
2019-01-11 18:06 ` Stephen Hemminger [this message]
2019-01-11 19:47 ` [dpdk-dev] [PATCH 0/6] net/tap: fixes and cleanups Wiles, Keith
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 " Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 1/7] net/tap: use strlcpy for interface name Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 2/7] net/tap: allow full length names Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 3/7] net/tap: check interface name in kvargs Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 4/7] net/tap: lower the priority of log messages Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 5/7] net/tap: let kernel choose tun device name Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 6/7] net/tap: get rid of global tuntap_name Stephen Hemminger
2019-01-11 20:35 ` [dpdk-dev] [PATCH v2 7/7] net/tap: don't print pointer in info message Stephen Hemminger
2019-01-14 14:10 ` Ferruh Yigit
2019-01-14 15:07 ` Wiles, Keith
2019-01-14 14:10 ` [dpdk-dev] [PATCH v2 0/6] net/tap: fixes and cleanups Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190111180659.5972-7-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).