All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org,
	michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
	hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me,
	eddie.wai@broadcom.com, prashant@broadcom.com,
	huangjw@broadcom.com, gospo@broadcom.com, brett.creeley@amd.com,
	ap420073@gmail.com, joe@dama.to, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net 4/5] eth: bnxt: free XDP frags when xdp_do_redirect() fails
Date: Tue, 27 Oct 2026 16:49:39 -0700	[thread overview]
Message-ID: <20261027234940.1267225-5-kuba@kernel.org> (raw)
In-Reply-To: <20261027234940.1267225-1-kuba@kernel.org>

When xdp_do_redirect() fails bnxt_rx_xdp() recycles the head page but
not the frags of a multi-buffer frame. Their agg ring slots have
already been refilled, so the pages leak, and the page pool can't be
destroyed until they are returned, which will never happen. Redirect
to an AF_XDP socket in copy mode fails this way with -ENOMEM whenever
the socket's fill ring runs out of buffers.
A socket bound without XDP_USE_SG also fails with -ENOSPC for every
frame that doesn't fit in a single chunk.

All the other drop paths in this function free the frags.

Pointed out in LLM review of the first patch of the series.
Tested on a BCM57504 at MTU 9000 by redirecting 60k 8000B ICMPv6
echo requests (a head and two agg buffers each) to lo, which can't
transmit XDP frames. The page pools' inflight count stayed flat
rather than growing by two pages per frame.

Fixes: a7559bc8c17c ("bnxt: support transmit and free of aggregation buffers")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
index 96845c8646e0..161e0dd62be6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
@@ -307,6 +307,7 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,
 
 		if (xdp_do_redirect(bp->dev, xdp, xdp_prog)) {
 			trace_xdp_exception(bp->dev, xdp_prog, act);
+			bnxt_xdp_buff_frags_free(rxr, xdp);
 			page_pool_recycle_direct(rxr->page_pool, page);
 			return true;
 		}
-- 
2.56.0


  parent reply	other threads:[~2026-10-27 23:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 23:49 [PATCH net 0/5] eth: bnxt: fix Rx buffer leaks under OOM Jakub Kicinski
2026-10-27 23:49 ` [PATCH net 1/5] eth: bnxt: recycle agg buffers when Rx head buffer allocation fails Jakub Kicinski
2026-10-28  6:58   ` Michael Chan
2026-10-28 23:52   ` netdev-bot+sashiko
2026-10-29  0:49     ` Jakub Kicinski
2026-10-27 23:49 ` [PATCH net 2/5] eth: bnxt: resize Rx head buffers when rx-copybreak changes Jakub Kicinski
2026-10-28 23:52   ` netdev-bot+sashiko
2026-10-29  0:58     ` Jakub Kicinski
2026-10-29  5:32       ` Michael Chan
2026-10-27 23:49 ` [PATCH net 3/5] eth: bnxt: don't leak buffers when XDP agg buffer allocation fails Jakub Kicinski
2026-10-27 23:49 ` Jakub Kicinski [this message]
2026-10-29  5:49   ` [PATCH net 4/5] eth: bnxt: free XDP frags when xdp_do_redirect() fails Michael Chan
2026-10-27 23:49 ` [PATCH net 5/5] eth: bnxt: hand XDP frags over to the copybreak skb Jakub Kicinski
2026-10-29  5:59 ` [PATCH net 0/5] eth: bnxt: fix Rx buffer leaks under OOM Michael Chan

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=20261027234940.1267225-5-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ap420073@gmail.com \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=eddie.wai@broadcom.com \
    --cc=edumazet@google.com \
    --cc=gospo@broadcom.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=huangjw@broadcom.com \
    --cc=joe@dama.to \
    --cc=john.fastabend@gmail.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=prashant@broadcom.com \
    --cc=sdf@fomichev.me \
    /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.