DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>,
	Jianfeng Tan <jianfeng.tan@intel.com>
Subject: [PATCH v4 5/8] eal: fix IPC request when no handler is registered
Date: Wed,  2 Dec 2026 10:07:38 -0800	[thread overview]
Message-ID: <20261202180820.4107462-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20261202180820.4107462-1-stephen@networkplumber.org>

A process only answers an IPC request if it registered an action for
that name. When no action is found the request is dropped silently
unless EAL init is still in progress, so the requester waits for the
full timeout and then sees ETIMEDOUT.

This is what happens when a primary broadcasts a pdump request and any
secondary did not call rte_pdump_init() then the primary would
wait for timeout on response. The secondary should just respond
with MP_IGN.

When secondary sends a request to primary that has not registered
an action, then the primary needs to respond to secondary with
new reply MP_ERR indicating that this action is not supported.

A secondary request to a primary that is still initializing now
fails with ENOTSUP. Before it got MP_IGN and the request returned
success with no replies. Waiting is not an option since there is no
way to know whether the primary will ever register that action.

The async path counts an MP_ERR as processed so the callback still
runs. No in tree user can reach that case today, since the only
async requests go from secondary to primary, but rte_mp_request_async
is public and dropping the reply would leave its callback pending.

Fixes: 579a4ccc345c ("eal: ignore IPC messages until init is complete")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_proc.c | 55 ++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 20 deletions(-)

diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
index b70e9189a4..65dceed1b6 100644
--- a/lib/eal/common/eal_common_proc.c
+++ b/lib/eal/common/eal_common_proc.c
@@ -32,7 +32,6 @@
 #include "eal_memcfg.h"
 #include "eal_private.h"
 #include "eal_filesystem.h"
-#include "eal_internal_cfg.h"
 
 static RTE_ATOMIC(int) mp_fd = -1;
 static rte_thread_t mp_handle_tid;
@@ -58,6 +57,7 @@ enum mp_type {
 	MP_REQ, /* Request for information, Will block for a reply */
 	MP_REP, /* Response to previously-received request */
 	MP_IGN, /* Response telling requester to ignore this response */
+	MP_ERR, /* Response telling requester that request not handled */
 };
 
 /* Message sent from primary EAL to secondary EAL */
@@ -357,25 +357,27 @@ cleanup_msg_fds(const struct rte_mp_msg *msg)
 static void
 process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
 {
-	struct pending_request *pending_req;
 	struct action_entry *entry;
 	struct rte_mp_msg *msg = &m->msg;
 	rte_mp_t action = NULL;
-	const struct internal_config *internal_conf =
-		eal_get_internal_configuration();
 
 	EAL_LOG(DEBUG, "msg: %s", msg->name);
 
-	if (m->type == MP_REP || m->type == MP_IGN) {
+	if (m->type == MP_REP || m->type == MP_IGN || m->type == MP_ERR) {
+		struct pending_request *pending_req;
 		struct pending_request *req = NULL;
 
 		pthread_mutex_lock(&pending_requests.lock);
 		pending_req = find_request_by_name(s->sun_path, msg->name);
 		if (pending_req) {
 			memcpy(pending_req->reply, msg, sizeof(*msg));
-			/* -1 indicates that we've been asked to ignore */
-			pending_req->reply_received =
-				m->type == MP_REP ? 1 : -1;
+
+			if (m->type == MP_REP)
+				pending_req->reply_received = 1;
+			else if (m->type == MP_IGN)
+				pending_req->reply_received = -1;
+			else /* MP_ERR */
+				pending_req->reply_received = -2;
 
 			if (pending_req->type == REQUEST_TYPE_SYNC)
 				pthread_cond_signal(&pending_req->sync.cond);
@@ -398,18 +400,20 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
 		action = entry->action;
 	pthread_mutex_unlock(&mp_mutex_action);
 
-	if (!action) {
-		if (m->type == MP_REQ && !internal_conf->init_complete) {
-			/* if this is a request, and init is not yet complete,
-			 * and callback wasn't registered, we should tell the
-			 * requester to ignore our existence because we're not
-			 * yet ready to process this request.
+	if (action == NULL) {
+		if (m->type == MP_REQ) {
+			/*
+			 * No handler is registered, either because init is not
+			 * complete or because this process does not use the
+			 * feature. A secondary only gets broadcasts from the
+			 * primary and can ignore them. A primary must tell the
+			 * requester it is unsupported.
 			 */
-			struct rte_mp_msg dummy;
+			struct rte_mp_msg dummy = { 0 };
 
-			memset(&dummy, 0, sizeof(dummy));
 			strlcpy(dummy.name, msg->name, sizeof(dummy.name));
-			mp_send(&dummy, s->sun_path, MP_IGN);
+			mp_send(&dummy, s->sun_path,
+				rte_eal_process_type() == RTE_PROC_PRIMARY ? MP_ERR : MP_IGN);
 		} else {
 			EAL_LOG(ERR, "Cannot find action: %s",
 				msg->name);
@@ -501,6 +505,13 @@ process_async_request(struct pending_request *sr, const struct timespec *now)
 	} else if (sr->reply_received == -1) {
 		/* we were asked to ignore this process */
 		reply->nb_sent--;
+	} else if (sr->reply_received == -2) {
+		/*
+		 * peer has no handler for this request. Count it as
+		 * processed so the callback still runs, but not as
+		 * received since there is no reply to pass up.
+		 */
+		param->n_responses_processed++;
 	} else if (timeout) {
 		/* count it as processed response, but don't increment
 		 * nb_received.
@@ -1019,19 +1030,23 @@ mp_request_sync(const char *dst, struct rte_mp_msg *req,
 
 	TAILQ_REMOVE(&pending_requests.requests, &pending_req, next);
 
-	if (pending_req.reply_received == 0) {
+	switch (pending_req.reply_received) {
+	case 0:
 		EAL_LOG(ERR, "Fail to recv reply for request %s:%s",
 			dst, req->name);
 		rte_errno = ETIMEDOUT;
 		return -1;
-	}
-	if (pending_req.reply_received == -1) {
+	case -1:
 		EAL_LOG(DEBUG, "Asked to ignore response");
 		/* not receiving this message is not an error, so decrement
 		 * number of sent messages
 		 */
 		reply->nb_sent--;
 		return 0;
+	case -2:
+		EAL_LOG(DEBUG, "Request not supported");
+		rte_errno = ENOTSUP;
+		return -1;
 	}
 
 	tmp = realloc(reply->msgs, sizeof(msg) * (reply->nb_received + 1));
-- 
2.53.0


  parent reply	other threads:[~2026-12-02 18:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 14:16 [PATCH 0/4] pdump: fix capture on ports with hairpin queues Stephen Hemminger
2026-10-28 14:16 ` [PATCH 1/4] ethdev: reject hairpin queue in add first Rx callback Stephen Hemminger
2026-10-28 14:16 ` [PATCH 2/4] pdump: fix error code when adding callback fails Stephen Hemminger
2026-10-28 14:16 ` [PATCH 3/4] pdump: skip hairpin queues Stephen Hemminger
2026-10-28 14:16 ` [PATCH 4/4] pdump: undo partial enable on failure Stephen Hemminger
2026-11-27 21:07 ` [PATCH v2 0/6] pdump: fix bugs related to hairpin queues Stephen Hemminger
2026-11-27 21:07   ` [PATCH v2 1/6] ethdev: reject hairpin queue in add first Rx callback Stephen Hemminger
2026-11-27 21:07   ` [PATCH v2 2/6] pdump: fix error code when adding callback fails Stephen Hemminger
2026-11-27 21:07   ` [PATCH v2 3/6] pdump: validate queues before installing callbacks Stephen Hemminger
2026-11-27 21:07   ` [PATCH v2 4/6] pdump: release BPF filter on error Stephen Hemminger
2026-11-27 21:07   ` [PATCH v2 5/6] pdump: report secondary process failures Stephen Hemminger
2026-11-27 21:07   ` [PATCH v2 6/6] app/dumpcap: disable capture on the interface that failed Stephen Hemminger
2026-12-01 19:31 ` [PATCH v3 0/8] pdump: fix error handling on failed enable Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 1/8] ethdev: reject hairpin queue in add first Rx callback Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 2/8] pdump: fix error code when adding callback fails Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 3/8] pdump: validate queues before installing callbacks Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 4/8] pdump: release BPF filter on error Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 5/8] eal: fix IPC request when no handler is registered Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 6/8] test/mp: check request with no registered handler Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 7/8] pdump: report secondary process failures Stephen Hemminger
2026-12-01 19:31   ` [PATCH v3 8/8] test/pdump: check secondary process result Stephen Hemminger
2026-12-02 18:07 ` [PATCH v4 0/8] pdump: fix error handling on failed enable Stephen Hemminger
2026-12-02 18:07   ` [PATCH v4 1/8] ethdev: reject hairpin queue in add first Rx callback Stephen Hemminger
2026-12-02 18:07   ` [PATCH v4 2/8] pdump: fix error code when adding callback fails Stephen Hemminger
2026-12-02 18:07   ` [PATCH v4 3/8] pdump: validate queues before installing callbacks Stephen Hemminger
2026-12-02 18:07   ` [PATCH v4 4/8] pdump: release BPF filter on error Stephen Hemminger
2026-12-02 18:07   ` Stephen Hemminger [this message]
2026-12-02 18:07   ` [PATCH v4 6/8] test/mp: check request with no registered handler Stephen Hemminger
2026-12-02 18:07   ` [PATCH v4 7/8] pdump: report secondary process failures Stephen Hemminger
2026-12-02 18:07   ` [PATCH v4 8/8] test/pdump: check secondary process result 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=20261202180820.4107462-6-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    --cc=stable@dpdk.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