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, Reshma Pattan <reshma.pattan@intel.com>,
	Konstantin Ananyev <konstantin.ananyev@huawei.com>
Subject: [PATCH v3 7/8] pdump: report secondary process failures
Date: Tue,  1 Dec 2026 11:31:16 -0800	[thread overview]
Message-ID: <20261201193243.1008280-8-stephen@networkplumber.org> (raw)
In-Reply-To: <20261201193243.1008280-1-stephen@networkplumber.org>

The primary broadcasts an enable to every secondary but ignored the
replies, so a secondary that could not install its callbacks only
logged the error. The client was told the enable succeeded and had
no reason to clean up.

Return the first error from the enable replies. Disable the
processes that did enable, so a failed request leaves nothing
holding the ring. The undo carries the request's ring, so it only
removes the callbacks that this request installed, and a secondary
with none left is not an error.

A secondary need not own every port. Report a missing port as ENODEV
and let the secondary handler treat that as nothing to do, otherwise
a process started with a different set of devices would fail the
enable for the processes that did install callbacks.

The client has to wait longer than the primary can take, which is
the enable broadcast plus the undo broadcast.

A disable reply is not propagated. The primary has already removed
its own callbacks and a secondary started after the enable never
had any.

This depends on the IPC change earlier in this series. Without it a
secondary that never called rte_pdump_init() does not reply at all,
the broadcast times out, and every enable fails. Both patches have
to be backported together.

Fixes: 278f945402c5 ("pdump: add new library for packet capture")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/pdump/rte_pdump.c | 85 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 71 insertions(+), 14 deletions(-)

diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c
index 6b1de5c3ad..b57e4a7a33 100644
--- a/lib/pdump/rte_pdump.c
+++ b/lib/pdump/rte_pdump.c
@@ -261,7 +261,7 @@ pdump_tx(uint16_t port, uint16_t queue,
  */
 static int
 pdump_check_queues(uint16_t port, uint16_t queue, uint16_t end_q,
-		   bool rx, uint16_t operation)
+		   bool rx, uint16_t operation, const struct rte_ring *ring)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port];
 	bool all = queue == RTE_PDUMP_ALL_QUEUES;
@@ -297,7 +297,11 @@ pdump_check_queues(uint16_t port, uint16_t queue, uint16_t end_q,
 			return -EEXIST;
 		}
 		if (operation == DISABLE && cbs->cb == NULL) {
-			if (all)
+			/*
+			 * An undo carries the ring of the failed request and
+			 * only has to remove what that request installed.
+			 */
+			if (all || ring != NULL)
 				continue;
 			PDUMP_LOG_LINE(ERR,
 				"no existing %s callback for port=%u queue=%u",
@@ -486,7 +490,7 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 		PDUMP_LOG_LINE(ERR,
 			  "failed to get port id for device id=%s",
 			  p->device);
-		ret = -EINVAL;
+		ret = -ENODEV;
 		goto free_filter;
 	}
 
@@ -534,13 +538,13 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 	/* check all queues before changing any */
 	nb_queues = 0;
 	if (flags & RTE_PDUMP_FLAG_RX) {
-		ret = pdump_check_queues(port, queue, nb_rx_q, true, operation);
+		ret = pdump_check_queues(port, queue, nb_rx_q, true, operation, ring);
 		if (ret < 0)
 			goto free_filter;
 		nb_queues += ret;
 	}
 	if (flags & RTE_PDUMP_FLAG_TX) {
-		ret = pdump_check_queues(port, queue, nb_tx_q, false, operation);
+		ret = pdump_check_queues(port, queue, nb_tx_q, false, operation, ring);
 		if (ret < 0)
 			goto free_filter;
 		nb_queues += ret;
@@ -602,12 +606,13 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 	return ret;
 }
 
-static void
+static int
 pdump_request_to_secondary(const struct pdump_request *req)
 {
 	struct rte_mp_msg mp_req = { };
 	struct rte_mp_reply mp_reply;
 	struct timespec ts = {.tv_sec = MP_TIMEOUT_S, .tv_nsec = 0};
+	int ret = 0, i;
 
 	PDUMP_LOG_LINE(DEBUG, "forward req %s to secondary", pdump_opname(req->op));
 
@@ -615,14 +620,34 @@ pdump_request_to_secondary(const struct pdump_request *req)
 	strlcpy(mp_req.name, PDUMP_MP, sizeof(mp_req.name));
 	mp_req.len_param = sizeof(*req);
 
-	if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) != 0)
-		PDUMP_LOG_LINE(ERR, "rte_mp_request_sync failed");
+	if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) != 0) {
+		PDUMP_LOG_LINE(ERR, "rte_mp_request_sync failed: %s",
+			       rte_strerror(rte_errno));
+		return -rte_errno;
+	}
 
-	else if (mp_reply.nb_sent != mp_reply.nb_received)
-		PDUMP_LOG_LINE(ERR, "not all secondary's replied (sent %u recv %u)",
-			       mp_reply.nb_sent, mp_reply.nb_received);
+	/*
+	 * A secondary that failed has already undone its own callbacks.
+	 * A process without pdump registered is skipped by the IPC layer
+	 * rather than counted as a reply, so every reply here is from a
+	 * process that ran the request.
+	 */
+	for (i = 0; i < mp_reply.nb_received; i++) {
+		const struct pdump_response *resp =
+			(const struct pdump_response *)mp_reply.msgs[i].param;
+
+		if (resp->err_value != 0) {
+			PDUMP_LOG_LINE(ERR, "secondary failed to %s: %s",
+				       pdump_opname(req->op),
+				       rte_strerror(-resp->err_value));
+			if (ret == 0)
+				ret = resp->err_value;
+		}
+	}
 
 	free(mp_reply.msgs);
+
+	return ret;
 }
 
 /* Allocate temporary storage for passing state to the alarm thread for deferred handling */
@@ -682,6 +707,17 @@ pdump_handle_primary_request(const struct rte_mp_msg *mp_msg, const void *peer)
 
 		/* Can just do it now, no need for interrupt thread */
 		ret = set_pdump_rxtx_cbs(req);
+
+		/*
+		 * Not every secondary owns every port. A process that does
+		 * not have this one has nothing to install and must not fail
+		 * the request for the processes that do.
+		 */
+		if (ret == -ENODEV) {
+			PDUMP_LOG_LINE(DEBUG, "port %s not present, nothing to do",
+				       req->device);
+			ret = 0;
+		}
 	}
 
 	return pdump_send_response(req, ret, peer);
@@ -701,10 +737,30 @@ __pdump_request(void *param)
 	PDUMP_LOG_LINE(DEBUG, "primary pdump %s", pdump_opname(req->op));
 
 	ret = set_pdump_rxtx_cbs(req);
+	if (ret != 0)
+		goto respond;
 
 	/* Primary process is responsible for broadcasting request to all secondaries */
-	if (ret == 0)
-		pdump_request_to_secondary(req);
+	ret = pdump_request_to_secondary(req);
+
+	if (req->op != ENABLE) {
+		/*
+		 * The primary already removed its callbacks. A secondary
+		 * started after the enable never had any, so its failure
+		 * does not mean the capture is still live.
+		 */
+		ret = 0;
+	} else if (ret != 0) {
+		/* Undo the processes that did enable, the rest have nothing */
+		struct pdump_request undo = *req;
+
+		undo.op = DISABLE;
+		undo.prm = NULL;	/* no filter needed to remove callbacks */
+		set_pdump_rxtx_cbs(&undo);
+		pdump_request_to_secondary(&undo);
+	}
+
+respond:
 
 	pdump_send_response(req, ret, bundle->peer);
 	free(bundle);
@@ -883,7 +939,8 @@ pdump_prepare_client_request(const char *device, uint16_t queue,
 	int ret = -1;
 	struct rte_mp_msg mp_req, *mp_rep;
 	struct rte_mp_reply mp_reply;
-	struct timespec ts = {.tv_sec = MP_TIMEOUT_S, .tv_nsec = 0};
+	/* the primary may broadcast an enable and then an undo */
+	struct timespec ts = {.tv_sec = 2 * MP_TIMEOUT_S + 1, .tv_nsec = 0};
 	struct pdump_request *req = (struct pdump_request *)mp_req.param;
 	struct pdump_response *resp;
 
-- 
2.53.0


  parent reply	other threads:[~2026-12-01 19:33 UTC|newest]

Thread overview: 21+ 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   ` Stephen Hemminger [this message]
2026-12-01 19:31   ` [PATCH v3 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=20261201193243.1008280-8-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=reshma.pattan@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