From: Elad Nachman <eladv6@gmail.com>
To: ferruh.yigit@intel.com
Cc: dev@dpdk.org, erclists@gmail.com, iryzhov@nfware.com,
Elad Nachman <eladv6@gmail.com>
Subject: [dpdk-dev] [PATCH v2] kni: Fix request overwritten
Date: Fri, 24 Sep 2021 13:54:09 +0300 [thread overview]
Message-ID: <20210924105409.21711-1-eladv6@gmail.com> (raw)
Fix lack of multiple KNI requests handling support by introducing a
request in progress flag which will fail additional requests with
EAGAIN return code if the original request has not been processed
by user-space.
Bugzilla ID: 809
Signed-off-by: Elad Nachman <eladv6@gmail.com>
---
kernel/linux/kni/kni_net.c | 9 +++++++++
lib/kni/rte_kni.c | 2 ++
lib/kni/rte_kni_common.h | 1 +
3 files changed, 12 insertions(+)
diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 611719b5ee..927bf9537c 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -110,6 +110,7 @@ kni_net_process_request(struct net_device *dev, struct rte_kni_request *req)
void *resp_va;
uint32_t num;
int ret_val;
+ struct rte_kni_request *cur_req;
ASSERT_RTNL();
@@ -123,7 +124,15 @@ kni_net_process_request(struct net_device *dev, struct rte_kni_request *req)
mutex_lock(&kni->sync_lock);
+ /* Check that existing request has been processed: */
+ cur_req = (struct rte_kni_request *)kni->sync_kva;
+ if (cur_req->req_in_progress) {
+ ret = -EAGAIN;
+ goto fail;
+ }
+
/* Construct data */
+ req->req_in_progress = 1;
memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
if (num < 1) {
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index d3e236005e..0599e0356a 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -307,6 +307,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
kni->sync_addr = kni->m_sync_addr->addr;
dev_info.sync_va = kni->m_sync_addr->addr;
dev_info.sync_phys = kni->m_sync_addr->iova;
+ memset(kni->sync_addr, 0, sizeof(struct rte_kni_request));
kni->pktmbuf_pool = pktmbuf_pool;
kni->group_id = conf->group_id;
@@ -596,6 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni)
ret = kni_fifo_put(kni->resp_q, (void **)&req, 1);
else
ret = 1;
+ req->req_in_progress = 0;
if (ret != 1) {
RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n");
return -1; /* It is an error of can't putting the mbuf back */
diff --git a/lib/kni/rte_kni_common.h b/lib/kni/rte_kni_common.h
index b547ea5501..1973e467f9 100644
--- a/lib/kni/rte_kni_common.h
+++ b/lib/kni/rte_kni_common.h
@@ -40,6 +40,7 @@ enum rte_kni_req_id {
*/
struct rte_kni_request {
uint32_t req_id; /**< Request id */
+ uint32_t req_in_progress; /**< Request in progress flag */
RTE_STD_C11
union {
uint32_t new_mtu; /**< New MTU */
--
2.17.1
next reply other threads:[~2021-09-24 10:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 10:54 Elad Nachman [this message]
2021-10-04 13:01 ` [dpdk-dev] [PATCH v2] kni: Fix request overwritten Ferruh Yigit
2021-10-04 13:09 ` Elad Nachman
2021-10-04 14:03 ` Ferruh Yigit
2021-10-04 14:25 ` Elad Nachman
2021-10-04 14:51 ` Ferruh Yigit
2021-10-04 14:58 ` Elad Nachman
2021-10-04 15:48 ` Ferruh Yigit
2021-10-04 16:18 ` Elad Nachman
2021-10-04 16:59 ` Eric Christian
2021-10-04 18:27 ` Elad Nachman
2021-10-08 20:23 ` Ferruh Yigit
2021-10-08 21:11 ` Ferruh Yigit
2021-10-04 14:14 ` Eric Christian
2021-10-04 14:56 ` 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=20210924105409.21711-1-eladv6@gmail.com \
--to=eladv6@gmail.com \
--cc=dev@dpdk.org \
--cc=erclists@gmail.com \
--cc=ferruh.yigit@intel.com \
--cc=iryzhov@nfware.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.