patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] patch 'net/virtio-user: do not close tap when disabling queue pairs' has been queued to LTS release 18.11.7
@ 2020-02-14 17:02 Kevin Traynor
  2020-02-14 17:02 ` [dpdk-stable] patch 'net/virtio-user: check tap offload setting failure' " Kevin Traynor
                   ` (41 more replies)
  0 siblings, 42 replies; 43+ messages in thread
From: Kevin Traynor @ 2020-02-14 17:02 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: Stephen Hemminger, Maxime Coquelin, dpdk stable

Hi,

FYI, your patch has been queued to LTS release 18.11.7

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/20/20. 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.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/ebf749a4653c63d3f963139f509c1c9997ab7239

Thanks.

Kevin.

---
From ebf749a4653c63d3f963139f509c1c9997ab7239 Mon Sep 17 00:00:00 2001
From: Tiwei Bie <tiwei.bie@intel.com>
Date: Mon, 25 Nov 2019 16:14:40 +0800
Subject: [PATCH] net/virtio-user: do not close tap when disabling queue pairs

[ upstream commit 47ac9661b68275321fae0876cce743b9d17671fe ]

Do not close the tap fds when disabling queue pairs, instead,
we just need to unbind the backend. Otherwise, tap port can be
destroyed unexpectedly.

Fixes: e3b434818bbb ("net/virtio-user: support kernel vhost")

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/net/virtio/virtio_user/vhost_kernel.c | 34 +++++++++++++++----
 .../net/virtio/virtio_user/vhost_kernel_tap.c | 34 ++++++++++++-------
 .../net/virtio/virtio_user/vhost_kernel_tap.h |  8 +++++
 drivers/net/virtio/virtio_user/vhost_user.c   |  4 +++
 .../net/virtio/virtio_user/virtio_user_dev.c  |  5 ++-
 .../net/virtio/virtio_user/virtio_user_dev.h  |  1 +
 6 files changed, 65 insertions(+), 21 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c
index 6b19180d72..23972493ff 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -332,14 +332,32 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev,
 	vhostfd = dev->vhostfds[pair_idx];
 
+	if (dev->qp_enabled[pair_idx] == enable)
+		return 0;
+
 	if (!enable) {
-		if (dev->tapfds[pair_idx] >= 0) {
-			close(dev->tapfds[pair_idx]);
-			dev->tapfds[pair_idx] = -1;
+		tapfd = dev->tapfds[pair_idx];
+		if (vhost_kernel_set_backend(vhostfd, -1) < 0) {
+			PMD_DRV_LOG(ERR, "fail to set backend for vhost kernel");
+			return -1;
 		}
-		return vhost_kernel_set_backend(vhostfd, -1);
-	} else if (dev->tapfds[pair_idx] >= 0) {
+		if (req_mq && vhost_kernel_tap_set_queue(tapfd, false) < 0) {
+			PMD_DRV_LOG(ERR, "fail to disable tap for vhost kernel");
+			return -1;
+		}
+		dev->qp_enabled[pair_idx] = false;
 		return 0;
 	}
 
+	if (dev->tapfds[pair_idx] >= 0) {
+		tapfd = dev->tapfds[pair_idx];
+		if (vhost_kernel_tap_set_offload(tapfd, dev->features) == -1)
+			return -1;
+		if (req_mq && vhost_kernel_tap_set_queue(tapfd, true) < 0) {
+			PMD_DRV_LOG(ERR, "fail to enable tap for vhost kernel");
+			return -1;
+		}
+		goto set_backend;
+	}
+
 	if ((dev->features & (1ULL << VIRTIO_NET_F_MRG_RXBUF)) ||
 	    (dev->features & (1ULL << VIRTIO_F_VERSION_1)))
@@ -355,11 +373,13 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev,
 	}
 
+	dev->tapfds[pair_idx] = tapfd;
+
+set_backend:
 	if (vhost_kernel_set_backend(vhostfd, tapfd) < 0) {
 		PMD_DRV_LOG(ERR, "fail to set backend for vhost kernel");
-		close(tapfd);
 		return -1;
 	}
 
-	dev->tapfds[pair_idx] = tapfd;
+	dev->qp_enabled[pair_idx] = true;
 	return 0;
 }
diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
index fbd9e979d7..361011ce65 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
@@ -19,5 +19,5 @@
 #include "../virtio_pci.h"
 
-static int
+int
 vhost_kernel_tap_set_offload(int fd, uint64_t features)
 {
@@ -38,18 +38,16 @@ vhost_kernel_tap_set_offload(int fd, uint64_t features)
 	}
 
-	if (offload != 0) {
-		/* Check if our kernel supports TUNSETOFFLOAD */
-		if (ioctl(fd, TUNSETOFFLOAD, 0) != 0 && errno == EINVAL) {
-			PMD_DRV_LOG(ERR, "Kernel does't support TUNSETOFFLOAD\n");
-			return -ENOTSUP;
-		}
+	/* Check if our kernel supports TUNSETOFFLOAD */
+	if (ioctl(fd, TUNSETOFFLOAD, 0) != 0 && errno == EINVAL) {
+		PMD_DRV_LOG(ERR, "Kernel does't support TUNSETOFFLOAD\n");
+		return -ENOTSUP;
+	}
 
+	if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
+		offload &= ~TUN_F_UFO;
 		if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
-			offload &= ~TUN_F_UFO;
-			if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
-				PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s\n",
-					strerror(errno));
-				return -1;
-			}
+			PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s\n",
+				strerror(errno));
+			return -1;
 		}
 	}
@@ -58,4 +56,14 @@ vhost_kernel_tap_set_offload(int fd, uint64_t features)
 }
 
+int
+vhost_kernel_tap_set_queue(int fd, bool attach)
+{
+	struct ifreq ifr = {
+		.ifr_flags = attach ? IFF_ATTACH_QUEUE : IFF_DETACH_QUEUE,
+	};
+
+	return ioctl(fd, TUNSETQUEUE, &ifr);
+}
+
 int
 vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
index e0e95b4f59..5c4447b296 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
+++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
@@ -3,4 +3,8 @@
  */
 
+#ifndef _VHOST_KERNEL_TAP_H
+#define _VHOST_KERNEL_TAP_H
+
+#include <stdbool.h>
 #include <sys/ioctl.h>
 
@@ -38,2 +42,6 @@
 int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
 			 const char *mac, uint64_t features);
+int vhost_kernel_tap_set_offload(int fd, uint64_t features);
+int vhost_kernel_tap_set_queue(int fd, bool attach);
+
+#endif
diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index 0a88d5957e..a42cf480af 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -457,4 +457,7 @@ vhost_user_enable_queue_pair(struct virtio_user_dev *dev,
 	int i;
 
+	if (dev->qp_enabled[pair_idx] == enable)
+		return 0;
+
 	for (i = 0; i < 2; ++i) {
 		struct vhost_vring_state state = {
@@ -467,4 +470,5 @@ vhost_user_enable_queue_pair(struct virtio_user_dev *dev,
 	}
 
+	dev->qp_enabled[pair_idx] = enable;
 	return 0;
 }
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index f6356eabc6..a199350df9 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -534,6 +534,9 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
 
 	if (dev->vhostfds) {
-		for (i = 0; i < dev->max_queue_pairs; ++i)
+		for (i = 0; i < dev->max_queue_pairs; ++i) {
 			close(dev->vhostfds[i]);
+			if (dev->tapfds[i] >= 0)
+				close(dev->tapfds[i]);
+		}
 		free(dev->vhostfds);
 		free(dev->tapfds);
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 3e3a7b787f..d8a5070a28 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -41,4 +41,5 @@ struct virtio_user_dev {
 	char		path[PATH_MAX];
 	struct vring	vrings[VIRTIO_MAX_VIRTQUEUES];
+	bool		qp_enabled[VIRTIO_MAX_VIRTQUEUE_PAIRS];
 	struct virtio_user_backend_ops *ops;
 	pthread_mutex_t	mutex;
-- 
2.21.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-02-14 17:02:37.108535157 +0000
+++ 0001-net-virtio-user-do-not-close-tap-when-disabling-queu.patch	2020-02-14 17:02:36.907408856 +0000
@@ -1 +1 @@
-From 47ac9661b68275321fae0876cce743b9d17671fe Mon Sep 17 00:00:00 2001
+From ebf749a4653c63d3f963139f509c1c9997ab7239 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 47ac9661b68275321fae0876cce743b9d17671fe ]
+
@@ -11 +12,0 @@
-Cc: stable@dpdk.org
@@ -26 +27 @@
-index 5c81e8dd9f..2c805077af 100644
+index 6b19180d72..23972493ff 100644
@@ -29 +30 @@
-@@ -331,14 +331,32 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev,
+@@ -332,14 +332,32 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev,
@@ -67 +68 @@
-@@ -354,11 +372,13 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev,
+@@ -355,11 +373,13 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev,
@@ -84 +85 @@
-index 76bf75423e..2fbfecba12 100644
+index fbd9e979d7..361011ce65 100644
@@ -159 +160 @@
-index a4b5c25cd3..d8e083ba8b 100644
+index 0a88d5957e..a42cf480af 100644
@@ -177 +178 @@
-index ffbaa75b7e..1c6b26f8d3 100644
+index f6356eabc6..a199350df9 100644
@@ -180 +181 @@
-@@ -547,6 +547,9 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
+@@ -534,6 +534,9 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
@@ -192 +193 @@
-index ad86837717..3b6b6065a5 100644
+index 3e3a7b787f..d8a5070a28 100644
@@ -195,3 +196,3 @@
-@@ -50,4 +50,5 @@ struct virtio_user_dev {
- 	};
- 	struct virtio_user_queue packed_queues[VIRTIO_MAX_VIRTQUEUES];
+@@ -41,4 +41,5 @@ struct virtio_user_dev {
+ 	char		path[PATH_MAX];
+ 	struct vring	vrings[VIRTIO_MAX_VIRTQUEUES];
@@ -199 +199,0 @@
- 
@@ -200,0 +201 @@
+ 	pthread_mutex_t	mutex;


^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2020-02-14 17:06 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 17:02 [dpdk-stable] patch 'net/virtio-user: do not close tap when disabling queue pairs' has been queued to LTS release 18.11.7 Kevin Traynor
2020-02-14 17:02 ` [dpdk-stable] patch 'net/virtio-user: check tap offload setting failure' " Kevin Traynor
2020-02-14 17:02 ` [dpdk-stable] patch 'vhost: fix deadlock on port deletion' " Kevin Traynor
2020-02-14 17:02 ` [dpdk-stable] patch 'net/ixgbe: remove duplicate function declaration' " Kevin Traynor
2020-02-14 17:02 ` [dpdk-stable] patch 'net/dpaa: fix Rx offload flags on jumbo MTU set' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'ethdev: fix switching domain allocation' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'ethdev: fix secondary process memory overwrite' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'mk: avoid combining -r and -export-dynamic linker options' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'kni: rename variable with namespace prefix' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'cfgfile: fix symbols map' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'latency: fix calculation for multi-thread' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'mempool: fix anonymous populate' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'maintainers: update for failsafe and PCI library' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'maintainers: resign from flow API maintenance' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnxt: fix flow creation' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnxt: use macro for PCI log format' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnxt: do not log error if stats queried before start' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnxt: remove unnecessary memset' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/tap: fix memory leak when unregister intr handler' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnx2x: fix reset of scan FP flag' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnx2x: fix to sync fastpath Rx queue access' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnxt: fix alloc filter to use a common routine' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnxt: remove redundant if statement' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/bnx2x: fix VLAN stripped flag' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/mlx5: fix VXLAN-GPE item translation' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/octeontx: fix memory leak of MAC address table' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'app/testpmd: fix uninitialized members of MPLS' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'app/testpmd: fix initial value when setting PFC' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'app/testpmd: fix uninitialized members " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'net/failsafe: fix reported hash key size in device info' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'vhost: fix crash on port deletion' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'vhost: do not treat empty socket message as error' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'vhost/crypto: fix fetch size' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'vhost: fix packed virtqueue ready condition' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'vhost: catch overflow causing mmap of size 0' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'crypto/armv8: fix clang build' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'examples/fips_validation: fix cipher length for AES-GCM' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'common/cpt: remove redundant code in datapath' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'common/cpt: check cipher and auth keys are set' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'common/cpt: fix component for empty IOV buffer' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'bpf: fix headers install with meson' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'app/pdump: fix build with clang' " Kevin Traynor
2020-02-14 17:03 ` [dpdk-stable] patch 'mem: fix munmap in error unwind' " Kevin Traynor

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).