patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Haifeng Li <hfli@netitest.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/tap: let kernel choose tun device name' has been queued to LTS release 18.11.1
Date: Thu, 31 Jan 2019 15:49:00 +0000	[thread overview]
Message-ID: <20190131154901.5383-52-ktraynor@redhat.com> (raw)
In-Reply-To: <20190131154901.5383-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to LTS release 18.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/07/19. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Kevin Traynor

---
>From d3034e04e58ca7bed78182fa9a1439afe4a73d4b Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Fri, 11 Jan 2019 12:35:18 -0800
Subject: [PATCH] net/tap: let kernel choose tun device name

[ upstream commit b5235d61f3b7d2b1c2b9ee2601f3aca2b151b508 ]

Assigning tun and tap index in DPDK tap device driver is racy
and fails if used with primary/secondary. Instead use the kernel
feature of device wildcarding where if a name with %d is used
the kernel will fill in the next available device.

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

Reported-by: Haifeng Li <hfli@netitest.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by Keith Wiles <keith.wiles@intel.com>
---
 drivers/net/tap/rte_eth_tap.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index aef8b0b9f..a93429973 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -79,7 +79,4 @@ static const char *valid_arguments[] = {
 };
 
-static unsigned int tap_unit;
-static unsigned int tun_unit;
-
 static char tuntap_name[8];
 
@@ -151,6 +148,4 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
 	snprintf(ifr.ifr_name, IFNAMSIZ, "%s", pmd->name);
 
-	TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name);
-
 	fd = open(TUN_TAP_DEV_PATH, O_RDWR);
 	if (fd < 0) {
@@ -186,4 +181,11 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
 	}
 
+	/*
+	 * Name passed to kernel might be wildcard like dtun%d
+	 * and need to find the resulting device.
+	 */
+	TAP_LOG(DEBUG, "Device name is '%s'", ifr.ifr_name);
+	strlcpy(pmd->name, ifr.ifr_name, RTE_ETH_NAME_MAX_LEN);
+
 	if (is_keepalive) {
 		/*
@@ -1756,4 +1758,5 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 		goto error_exit;
 	}
+	TAP_LOG(DEBUG, "allocated %s", pmd->name);
 
 	ifr.ifr_mtu = dev->data->mtu;
@@ -1895,6 +1898,6 @@ set_interface_name(const char *key __rte_unused,
 		strlcpy(name, value, RTE_ETH_NAME_MAX_LEN);
 	else
-		snprintf(name, RTE_ETH_NAME_MAX_LEN, "%s%d",
-			 DEFAULT_TAP_NAME, tap_unit - 1);
+		/* use tap%d which causes kernel to choose next available */
+		strlcpy(name, DEFAULT_TAP_NAME "%d", RTE_ETH_NAME_MAX_LEN);
 
 	return 0;
@@ -2003,6 +2006,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
 	}
 
-	snprintf(tun_name, sizeof(tun_name), "%s%u",
-		 DEFAULT_TUN_NAME, tun_unit++);
+	/* use tun%d which causes kernel to choose next available */
+	strlcpy(tun_name, DEFAULT_TUN_NAME "%d", RTE_ETH_NAME_MAX_LEN);
 
 	if (params && (params[0] != '\0')) {
@@ -2024,9 +2027,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
 	pmd_link.link_speed = ETH_SPEED_NUM_10G;
 
-	TAP_LOG(NOTICE, "Initializing pmd_tun for %s as %s",
-		name, tun_name);
+	TAP_LOG(NOTICE, "Initializing pmd_tun for %s", name);
 
 	ret = eth_dev_tap_create(dev, tun_name, remote_iface, 0,
-		ETH_TUNTAP_TYPE_TUN);
+				 ETH_TUNTAP_TYPE_TUN);
 
 leave:
@@ -2034,5 +2036,4 @@ leave:
 		TAP_LOG(ERR, "Failed to create pmd for %s as %s",
 			name, tun_name);
-		tun_unit--; /* Restore the unit number */
 	}
 	rte_kvargs_free(kvlist);
@@ -2190,6 +2191,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
 
 	speed = ETH_SPEED_NUM_10G;
-	snprintf(tap_name, sizeof(tap_name), "%s%u",
-		 DEFAULT_TAP_NAME, tap_unit++);
+
+	/* use tap%d which causes kernel to choose next available */
+	strlcpy(tap_name, DEFAULT_TAP_NAME "%d", RTE_ETH_NAME_MAX_LEN);
 	memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
 
@@ -2255,5 +2257,4 @@ leave:
 			tap_devices_count--;
 		}
-		tap_unit--;		/* Restore the unit number */
 	}
 	rte_kvargs_free(kvlist);
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-01-31 15:44:06.948575581 +0000
+++ 0052-net-tap-let-kernel-choose-tun-device-name.patch	2019-01-31 15:44:05.000000000 +0000
@@ -1,15 +1,16 @@
-From b5235d61f3b7d2b1c2b9ee2601f3aca2b151b508 Mon Sep 17 00:00:00 2001
+From d3034e04e58ca7bed78182fa9a1439afe4a73d4b Mon Sep 17 00:00:00 2001
 From: Stephen Hemminger <stephen@networkplumber.org>
 Date: Fri, 11 Jan 2019 12:35:18 -0800
 Subject: [PATCH] net/tap: let kernel choose tun device name
 
+[ upstream commit b5235d61f3b7d2b1c2b9ee2601f3aca2b151b508 ]
+
 Assigning tun and tap index in DPDK tap device driver is racy
 and fails if used with primary/secondary. Instead use the kernel
 feature of device wildcarding where if a name with %d is used
 the kernel will fill in the next available device.
 
 Fixes: 02f96a0a82d1 ("net/tap: add TUN/TAP device PMD")
-Cc: stable@dpdk.org
 
 Reported-by: Haifeng Li <hfli@netitest.com>
 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
@@ -19,10 +20,10 @@
  1 file changed, 17 insertions(+), 16 deletions(-)
 
 diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
-index d699b4fb0..ed8483cb9 100644
+index aef8b0b9f..a93429973 100644
 --- a/drivers/net/tap/rte_eth_tap.c
 +++ b/drivers/net/tap/rte_eth_tap.c
-@@ -80,7 +80,4 @@ static const char *valid_arguments[] = {
+@@ -79,7 +79,4 @@ static const char *valid_arguments[] = {
  };
  
 -static unsigned int tap_unit;
@@ -30,14 +31,14 @@
 -
  static char tuntap_name[8];
  
-@@ -152,6 +149,4 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
- 	strlcpy(ifr.ifr_name, pmd->name, IFNAMSIZ);
+@@ -151,6 +148,4 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
+ 	snprintf(ifr.ifr_name, IFNAMSIZ, "%s", pmd->name);
  
 -	TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name);
 -
  	fd = open(TUN_TAP_DEV_PATH, O_RDWR);
  	if (fd < 0) {
-@@ -187,4 +182,11 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
+@@ -186,4 +181,11 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
  	}
  
 +	/*
@@ -49,22 +50,22 @@
 +
  	if (is_keepalive) {
  		/*
-@@ -1757,4 +1759,5 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
+@@ -1756,4 +1758,5 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
  		goto error_exit;
  	}
 +	TAP_LOG(DEBUG, "allocated %s", pmd->name);
  
  	ifr.ifr_mtu = dev->data->mtu;
-@@ -1919,6 +1922,6 @@ set_interface_name(const char *key __rte_unused,
+@@ -1895,6 +1898,6 @@ set_interface_name(const char *key __rte_unused,
  		strlcpy(name, value, RTE_ETH_NAME_MAX_LEN);
- 	} else {
+ 	else
 -		snprintf(name, RTE_ETH_NAME_MAX_LEN, "%s%d",
 -			 DEFAULT_TAP_NAME, tap_unit - 1);
 +		/* use tap%d which causes kernel to choose next available */
 +		strlcpy(name, DEFAULT_TAP_NAME "%d", RTE_ETH_NAME_MAX_LEN);
- 	}
+ 
  	return 0;
-@@ -2033,6 +2036,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
+@@ -2003,6 +2006,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
  	}
  
 -	snprintf(tun_name, sizeof(tun_name), "%s%u",
@@ -73,25 +74,25 @@
 +	strlcpy(tun_name, DEFAULT_TUN_NAME "%d", RTE_ETH_NAME_MAX_LEN);
  
  	if (params && (params[0] != '\0')) {
-@@ -2054,9 +2057,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
+@@ -2024,9 +2027,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
  	pmd_link.link_speed = ETH_SPEED_NUM_10G;
  
--	TAP_LOG(DEBUG, "Initializing pmd_tun for %s as %s",
+-	TAP_LOG(NOTICE, "Initializing pmd_tun for %s as %s",
 -		name, tun_name);
-+	TAP_LOG(DEBUG, "Initializing pmd_tun for %s", name);
++	TAP_LOG(NOTICE, "Initializing pmd_tun for %s", name);
  
  	ret = eth_dev_tap_create(dev, tun_name, remote_iface, 0,
 -		ETH_TUNTAP_TYPE_TUN);
 +				 ETH_TUNTAP_TYPE_TUN);
  
  leave:
-@@ -2064,5 +2066,4 @@ leave:
+@@ -2034,5 +2036,4 @@ leave:
  		TAP_LOG(ERR, "Failed to create pmd for %s as %s",
  			name, tun_name);
 -		tun_unit--; /* Restore the unit number */
  	}
  	rte_kvargs_free(kvlist);
-@@ -2220,6 +2221,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
+@@ -2190,6 +2191,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
  
  	speed = ETH_SPEED_NUM_10G;
 -	snprintf(tap_name, sizeof(tap_name), "%s%u",
@@ -101,7 +102,7 @@
 +	strlcpy(tap_name, DEFAULT_TAP_NAME "%d", RTE_ETH_NAME_MAX_LEN);
  	memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
  
-@@ -2284,5 +2286,4 @@ leave:
+@@ -2255,5 +2257,4 @@ leave:
  			tap_devices_count--;
  		}
 -		tap_unit--;		/* Restore the unit number */

  parent reply	other threads:[~2019-01-31 15:51 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 15:48 [dpdk-stable] patch 'net/i40e: fix get RSS conf' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'devtools: fix wrong headline lowercase for arm' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'drivers/crypto: fix PMDs memory leak' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'doc: fix AESNI_MB guide' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'compress/qat: fix returned status on overflow' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'test/crypto: fix misleading trace message' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'examples/ipsec-secgw: fix crypto-op might never get dequeued' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'examples/ipsec-secgw: fix outbound codepath for single SA' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'examples/ipsec-secgw: make local variables static' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'examples/ipsec-secgw: fix inbound SA checking' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'app/bbdev: fix return value check' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'crypto/dpaa2_sec: fix FLC address for physical mode' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'build: use static deps for pkg-config libs.private' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'build: fix variable name in dependency error message' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'devtools: fix build check for whether meson has run' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'kni: fix build on RHEL 8' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'eal: fix strdup usages in internal config' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'vfio: do not unregister callback in secondary process' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'mem: fix variable shadowing' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'mem: fix storing old policy' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'mk: fix scope of disabling AVX512F support' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'eal: fix build of external app with clang on armv8' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/mlx5: fix shared counter allocation logic' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/ixgbe: fix over using multicast table for VF' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'vhost: fix possible out of bound access in vector filling' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'vhost: fix possible dead loop " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'vhost: ensure event idx is mapped when negotiated' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'vhost/crypto: fix possible dead loop' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'vhost/crypto: fix possible out of bound access' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/fm10k: fix internal switch initial status' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'bus/dpaa: fix logical to physical core affine logic' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/dpaa: fix secondary process' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'examples/flow_filtering: fix example documentation' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'doc: fix a typo in testpmd guide' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'doc: fix a parameter name " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'app/testpmd: fix quit to stop all ports before close' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/bonding: fix possible null pointer reference' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/sfc: add missing header guard to TSO header file' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/sfc: discard last seen VLAN TCI if Tx packet is dropped' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/sfc/base: fix Tx descriptor max number check' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/virtio: add barrier before reading the flags' " Kevin Traynor
2019-01-31 16:02   ` Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'bus/fslmc: fix to reset portal memory before use' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'bus/fslmc: fix ring mode to use correct cache settings' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'bus/fslmc: fix to use correct physical core for logical core' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/dpaa2: fix bad check for not-null' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'bus/fslmc: fix to convert error msg to warning' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'bus/fslmc: fix parse method for bus devices' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/dpaa2: fix device init for secondary process' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'doc: fix MAC address rewrite actions in prog guide' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/sfc: fix typo in preprocessor check' " Kevin Traynor
2019-01-31 15:48 ` [dpdk-stable] patch 'net/tap: allow full length names' " Kevin Traynor
2019-01-31 15:49 ` Kevin Traynor [this message]
2019-01-31 15:49 ` [dpdk-stable] patch 'net/i40e: perform basic validation on VF messages' " Kevin Traynor
     [not found] <003901d4ba18$ee13bf40$ca3b3dc0$@netitest.com>
2019-02-05 12:57 ` [dpdk-stable] 答复: patch 'net/tap: let kernel choose tun device name' " Kevin Traynor
2019-02-06 17:45 ` [dpdk-stable] " Stephen Hemminger

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=20190131154901.5383-52-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=hfli@netitest.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.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).