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 v4 4/8] pdump: release BPF filter on error
Date: Wed,  2 Dec 2026 10:07:37 -0800	[thread overview]
Message-ID: <20261202180820.4107462-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20261202180820.4107462-1-stephen@networkplumber.org>

The BPF filter loaded for a request was leaked if the request
failed. A successful enable keeps it, the callbacks reference it.

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 | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c
index eb4bd11acc..6b1de5c3ad 100644
--- a/lib/pdump/rte_pdump.c
+++ b/lib/pdump/rte_pdump.c
@@ -486,7 +486,8 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 		PDUMP_LOG_LINE(ERR,
 			  "failed to get port id for device id=%s",
 			  p->device);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto free_filter;
 	}
 
 	ret = rte_eth_dev_info_get(port, &dev_info);
@@ -494,7 +495,7 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 		PDUMP_LOG_LINE(ERR,
 			"Error during getting device (port %u) info: %s",
 			port, strerror(-ret));
-		return ret;
+		goto free_filter;
 	}
 
 	if (queue == RTE_PDUMP_ALL_QUEUES) {
@@ -503,25 +504,29 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 		if (nb_rx_q == 0 && flags & RTE_PDUMP_FLAG_RX) {
 			PDUMP_LOG_LINE(ERR,
 				"number of rx queues cannot be 0");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_filter;
 		}
 		if (nb_tx_q == 0 && flags & RTE_PDUMP_FLAG_TX) {
 			PDUMP_LOG_LINE(ERR,
 				"number of tx queues cannot be 0");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_filter;
 		}
 		if ((nb_tx_q == 0 || nb_rx_q == 0) &&
 			flags == RTE_PDUMP_FLAG_RXTX) {
 			PDUMP_LOG_LINE(ERR,
 				"both tx&rx queues must be non zero");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_filter;
 		}
 	} else {
 		if (((flags & RTE_PDUMP_FLAG_RX) && queue >= dev_info.nb_rx_queues) ||
 		    ((flags & RTE_PDUMP_FLAG_TX) && queue >= dev_info.nb_tx_queues)) {
 			PDUMP_LOG_LINE(ERR,
 				"invalid queue %u for port %u", queue, port);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_filter;
 		}
 		nb_rx_q = nb_tx_q = queue + 1;
 	}
@@ -531,13 +536,13 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 	if (flags & RTE_PDUMP_FLAG_RX) {
 		ret = pdump_check_queues(port, queue, nb_rx_q, true, operation);
 		if (ret < 0)
-			return ret;
+			goto free_filter;
 		nb_queues += ret;
 	}
 	if (flags & RTE_PDUMP_FLAG_TX) {
 		ret = pdump_check_queues(port, queue, nb_tx_q, false, operation);
 		if (ret < 0)
-			return ret;
+			goto free_filter;
 		nb_queues += ret;
 	}
 
@@ -549,7 +554,8 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 	if (nb_queues == 0 && operation == ENABLE) {
 		PDUMP_LOG_LINE(ERR, "no queue available to capture on port=%u",
 			port);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto free_filter;
 	}
 
 	/* register RX callback */
@@ -589,6 +595,10 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
 						    DISABLE, p->snaplen);
 	}
 
+free_filter:
+	if (filter != NULL)
+		rte_bpf_destroy(filter);
+
 	return ret;
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-12-02 18:08 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   ` Stephen Hemminger [this message]
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   ` [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-5-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