All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH] net/pcap: fix handling of transmit errors
Date: Mon, 16 Nov 2026 15:28:34 -0800	[thread overview]
Message-ID: <20261116232834.1190655-1-stephen@networkplumber.org> (raw)

The pcap PMD assumed that every error from pcap_sendpacket()
was from back pressure. But in the case of bad mbuf or file system
full or other hard errors, the packet needs to be dropped.

Bugzilla ID: 2132
Fixes: cf91cce204ea ("net/pcap: fix error accounting and backpressure on Tx")

Reported-by: Anthropic OSS scanner (ANT-2026-DLCI8IK6)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/pcap/pcap_ethdev.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index fb18f0932b..e7a8f007e0 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -607,16 +607,6 @@ eth_tx_drop(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 /*
  * Send a burst of packets to a pcap device.
- *
- * On Linux, pcap_sendpacket() calls send() on a blocking PF_PACKET
- * socket with default kernel buffer sizes and no TX ring (PACKET_TX_RING).
- * The send() call only blocks when the kernel socket send buffer is full,
- * providing limited backpressure.
- *
- * On error, pcap_sendpacket() returns non-zero and the loop breaks,
- * leaving remaining packets unsent.
- *
- * Bottom line: backpressure is not an error.
  */
 static uint16_t
 eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
@@ -666,10 +656,18 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		data = rte_pktmbuf_read(mbuf, 0, len, temp_data);
 		RTE_ASSERT(data != NULL);
 
+		errno = 0;
 		if (unlikely(pcap_sendpacket(pcap, data, len) != 0)) {
+			/* retry on soft errors */
+			if (errno == EINTR || errno == EAGAIN ||
+			    errno == EWOULDBLOCK)
+				break;
+
 			/* Assume failure is backpressure */
 			PMD_LOG(ERR, "pcap_sendpacket() failed: %s", pcap_geterr(pcap));
-			break;
+			rte_pktmbuf_free(mbuf);
+			tx_queue->tx_stat.err_pkts++;
+			continue;
 		}
 		num_tx++;
 		tx_bytes += len;
-- 
2.53.0


             reply	other threads:[~2026-11-16 23:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 23:28 Stephen Hemminger [this message]
2026-11-17 18:32 ` [PATCH v2] net/pcap: fix handling of transmit errors Stephen Hemminger
2026-11-22 18:06   ` 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=20261116232834.1190655-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --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 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.