DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 05/10] kni: don't run rte_kni_handle_request after interface release
@ 2018-06-28 22:52 Dan Gora
  0 siblings, 0 replies; only message in thread
From: Dan Gora @ 2018-06-28 22:52 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev, Dan Gora

Check to ensure that the KNI interface is still in use before accessing
the KNI interface FIFOs to kernel space.

This will help to ensure that the user does not access the KNI
interface after rte_kni_release() has been called.

Signed-off-by: Dan Gora <dg@adax.com>
---
 lib/librte_kni/rte_kni.c | 6 +++++-
 lib/librte_kni/rte_kni.h | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 1d84c0b70..6ef0859bf 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -578,7 +578,11 @@ rte_kni_handle_request(struct rte_kni *kni)
 	unsigned ret;
 	struct rte_kni_request *req;
 
-	if (kni == NULL)
+	/*
+	 * Don't touch the req/resp fifos after
+	 * we've been released, we can be freed at any instant!
+	 */
+	if (kni == NULL || !kni->in_use)
 		return -1;
 
 	/* Get request mbuf */
diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h
index d1a95f898..94516c38f 100644
--- a/lib/librte_kni/rte_kni.h
+++ b/lib/librte_kni/rte_kni.h
@@ -155,6 +155,10 @@ rte_kni_free(struct rte_kni *kni);
  * Then analyzes it and calls the specific actions for the specific requests.
  * Finally constructs the response mbuf and puts it back to the resp_q.
  *
+ * Thread Safety: This function should be called in a separate thread from the
+ * thread which calls rte_kni_release() for this KNI.  This function must not
+ * be called simultaneously with rte_kni_free().
+ *
  * @param kni
  *  The pointer to the context of an existent KNI interface.
  *
-- 
2.18.0.rc1.1.g6f333ff2f

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-28 22:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 22:52 [dpdk-dev] [PATCH 05/10] kni: don't run rte_kni_handle_request after interface release Dan Gora

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