From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id C45F01BBDC for ; Fri, 11 Jan 2019 21:35:36 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id 64so7459425pfr.9 for ; Fri, 11 Jan 2019 12:35:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gU7tWRWDcg78/QteNhNJDrakoTGeFzFmIYUxBmCVUek=; b=0a2+Yx+qNSAA808LtdY1G4vALGEQ1jnAs39S5PPkHSdBLqXikcC6UucplugJ4c23Yc hzlCuKLPCzHgrX5E0eDAQiKytTUxYEy7rXpURv3vZ8k2yHgl4Efcxm3gJF4l4Akdu/cH RfiOnMpKkT5vcrumMA8n/85h62XsprZ9Si8R0QQzm4jQV3E1g9sEsbN4lksQw9Zv2Kb2 erlMDYHfWTdZyf+zagi0H8G98gwMDqbXuSkogp4TlnLmSXHwT5+slCqf9vYvZOteBL/Y ZqT8On2BFMRTlGv9wIc26E5+ODxEghWILgOxu9FpLMKyL5Xh56/D8CbX37ije0AW+dh/ 6Vog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gU7tWRWDcg78/QteNhNJDrakoTGeFzFmIYUxBmCVUek=; b=K0Tb1w77NKSEeyr2FpOUV0zl4IG41MRZ+9lbZYBOwq0be3lTCL8iZlfvxvFdFy3MpH uYmi5URSQuo7pHhRA9yBBEU1Z8buhip7KNs/BqnIojgd7DVUOqoMxoPTGZpkzMOIryHg cWJobF/rbE1pbs0rKw5Lkr54xKQrPDK8z9IZNcLQYCuFvavPBJyFajaTyin3uaMoMGQe P37W4mU+oEGqiQ/7K77uI5sMnny2p49Yx10MKo5RxH/Cvbq7W1dCXOfhP43WrcFrgKzR 4iZNWqa957wcnZ2XFJRgRBQFNtryziAdsLugBX6bJiDQJGd7joyf4TOqsaPDOF65Ezu/ o2qA== X-Gm-Message-State: AJcUukcyYlmOuPcZB4f/2utHnCdsa9mHjoZwHal8h59QTYvW/OkuzdAj A/mEqe1kckzC6BJ2mfiYottyDw== X-Google-Smtp-Source: ALg8bN4wEB+ACxs9MNTywLs+9xvA0X5DDcUbM7k6XPQvdaHAGiqGkQCP22E9JqHSgDH6NjjIkfR4Gg== X-Received: by 2002:a62:6204:: with SMTP id w4mr16176921pfb.5.1547238935909; Fri, 11 Jan 2019 12:35:35 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id f32sm96610438pgf.80.2019.01.11.12.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 12:35:34 -0800 (PST) From: Stephen Hemminger To: keith.wiles@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Fri, 11 Jan 2019 12:35:19 -0800 Message-Id: <20190111203520.19944-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111203520.19944-1-stephen@networkplumber.org> References: <20190111180659.5972-1-stephen@networkplumber.org> <20190111203520.19944-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 6/7] net/tap: get rid of global tuntap_name 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: Fri, 11 Jan 2019 20:35:37 -0000 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 Acked-by Keith Wiles --- 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 ed8483cb96bc..705c90dadee5 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) { @@ -2016,8 +2017,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); @@ -2182,8 +2181,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); @@ -2266,8 +2263,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; } } @@ -2316,8 +2313,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