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>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [PATCH v4 6/8] test/mp: check request with no registered handler
Date: Wed,  2 Dec 2026 10:07:39 -0800	[thread overview]
Message-ID: <20261202180820.4107462-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20261202180820.4107462-1-stephen@networkplumber.org>

Add coverage for requests the peer has no action for. The secondary
asks the primary for an action nobody registered and checks that the
call fails with ENOTSUP rather than blocking until the timeout.

The async form of the same request is checked as well. Its callback
has to run even though no reply comes back, reporting the request as
sent and nothing received.

The MP_IGN direction is not covered here. That needs a primary
broadcasting to a secondary which did not register the action, and
the test primary is blocked waiting for the secondary to exit.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_mp_secondary.c | 85 +++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)

diff --git a/app/test/test_mp_secondary.c b/app/test/test_mp_secondary.c
index d89419c253..8101c2cafc 100644
--- a/app/test/test_mp_secondary.c
+++ b/app/test/test_mp_secondary.c
@@ -53,6 +53,7 @@ test_mp_secondary(void)
 #endif /* RTE_LIB_LPM */
 
 #include <rte_string_fns.h>
+#include <rte_cycles.h>
 
 #include "process.h"
 
@@ -197,6 +198,85 @@ run_object_creation_tests(void)
 	return 0;
 }
 
+#define NO_SUCH_ACTION "test_mp_no_action"
+#define MP_WAIT_S 5
+
+static int async_replied;
+static int async_nb_sent;
+static int async_nb_received;
+
+static int
+unsupported_async_reply(const struct rte_mp_msg *request __rte_unused,
+			const struct rte_mp_reply *reply)
+{
+	async_nb_sent = reply->nb_sent;
+	async_nb_received = reply->nb_received;
+	async_replied = 1;
+	return 0;
+}
+
+/*
+ * Run in the secondary to check requests the primary has no handler for.
+ * The primary answers MP_ERR, so the request fails right away instead of
+ * waiting for the timeout.
+ */
+static int
+run_unsupported_request_tests(void)
+{
+	struct timespec ts = { .tv_sec = MP_WAIT_S, .tv_nsec = 0 };
+	struct rte_mp_msg msg = { .len_param = 0, .num_fds = 0 };
+	struct rte_mp_reply reply = { };
+	time_t start;
+	int ret;
+
+	printf("### Testing request with no handler in primary:\n");
+
+	strlcpy(msg.name, NO_SUCH_ACTION, sizeof(msg.name));
+
+	start = time(NULL);
+	ret = rte_mp_request_sync(&msg, &reply, &ts);
+	if (ret == 0 || rte_errno != ENOTSUP) {
+		printf("Error: rte_mp_request_sync() returned %d errno %d, expected -1/ENOTSUP\n",
+		       ret, rte_errno);
+		free(reply.msgs);
+		return -1;
+	}
+	/* a dropped request would have cost the full timeout */
+	if (time(NULL) - start >= MP_WAIT_S) {
+		printf("Error: rte_mp_request_sync() waited for the timeout\n");
+		return -1;
+	}
+	printf("# Checked rte_mp_request_sync() returns ENOTSUP\n");
+
+	async_replied = 0;
+	if (rte_mp_request_async(&msg, &ts, unsupported_async_reply) != 0) {
+		printf("Error: rte_mp_request_async() failed: %s\n",
+		       rte_strerror(rte_errno));
+		return -1;
+	}
+
+	/* the callback runs on the interrupt thread */
+	for (int i = 0; i < MP_WAIT_S * 10 && !async_replied; i++)
+		rte_delay_ms(100);
+
+	if (!async_replied) {
+		printf("Error: rte_mp_request_async() callback never ran\n");
+		return -1;
+	}
+	/*
+	 * The request was sent and answered with an error, so the callback
+	 * must see it as sent but carrying no reply.
+	 */
+	if (async_nb_sent != 1 || async_nb_received != 0) {
+		printf("Error: async reply sent %d received %d, expected 1/0\n",
+		       async_nb_sent, async_nb_received);
+		return -1;
+	}
+	printf("# Checked rte_mp_request_async() callback runs with no reply\n");
+
+	return 0;
+}
+
 /* if called in a primary process, just spawns off a secondary process to
  * run validation tests - which brings us right back here again...
  * if called in a secondary process, this runs a series of API tests to check
@@ -211,7 +291,10 @@ test_mp_secondary(void)
 
 	printf("IN SECONDARY PROCESS\n");
 
-	return run_object_creation_tests();
+	if (run_object_creation_tests() < 0)
+		return -1;
+
+	return run_unsupported_request_tests();
 }
 
 #endif /* !RTE_EXEC_ENV_WINDOWS */
-- 
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   ` [PATCH v4 5/8] eal: fix IPC request when no handler is registered Stephen Hemminger
2026-12-02 18:07   ` Stephen Hemminger [this message]
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-7-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@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