๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27058

Re: [PATCH net-next v2] eth: fbnic: Support XDP redirect

#27058
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 18:11
113 lines
12105 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] This patch lets fbnic hand multi-buffer XDP frames to redirect
  targets.

--

eth: fbnic: Support XDP redirect

This commit adds the XDP_REDIRECT verdict to fbnic_run_xdp() and
advertises NETDEV_XDP_ACT_REDIRECT. Each RX queue flushes its pending
redirects once per poll, and a flag in the NAPI vector records when a
flush is needed.

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> index 381831b7e1080..9525ad2f7e14d 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c

[ ... ]

> @@ -1211,10 +1212,15 @@ static struct sk_buff *fbnic_run_xdp(struct fbnic_napi_vector *nv,
>  		return fbnic_build_skb(nv, pkt);
>  	case XDP_TX:
>  		return ERR_PTR(fbnic_pkt_tx(nv, pkt));
> +	case XDP_REDIRECT:
> +		if (xdp_do_redirect(nv->napi.dev, &pkt->buff, xdp_prog))
> +			goto xdp_exception;
> +		return ERR_PTR(-FBNIC_XDP_REDIRECT);

[Severity: High]
Can multi-buffer frames redirected from fbnic end up as skbs whose
truesize is much smaller than the memory they hold?

REDIRECT is now advertised together with NETDEV_XDP_ACT_RX_SG. That means
a header-split frame with payload frags can reach a cpumap (or veth).
There, cpu_map_kthread_run() builds the skb with
__xdp_build_skb_from_frame(), which ignores sinfo->xdp_frags_truesize:

net/core/xdp.c:__xdp_build_skb_from_frame() {
    ...
	if (unlikely(xdp_frame_has_frags(xdpf)))
		xdp_update_skb_frags_info(skb, nr_frags, sinfo->xdp_frags_size,
					  nr_frags * xdpf->frame_sz,
					  xdp_frame_get_skb_flags(xdpf));
    ...
}

In fbnic, frame_sz only covers the header chunk:

drivers/net/ethernet/meta/fbnic/fbnic_txrx.c:fbnic_pkt_prepare() {
    ...
	frame_sz = hdr_pg_end - hdr_pg_start;
	xdp_init_buff(&pkt->buff, frame_sz, &qt->xdp_rxq);
    ...
}

With FBNIC_RX_HROOM and FBNIC_RX_TROOM, that comes to roughly 704 bytes
for a split TCP header.

The payload frags are added in fbnic_add_rx_frag() with their real
truesize, which can be up to FBNIC_BD_PAGE_SIZE - pg_off:

	added = xdp_buff_add_frag(&pkt->buff, netmem, pg_off, len, truesize);

xdp_buff_add_frag() can also coalesce adjacent device pages into one
frag. So a 9000-byte jumbo payload could end up as nr_frags == 1 with
about 9 KiB of real truesize, yet it would be charged only frame_sz.

The XDP_PASS path avoids this, because xdp_build_skb_from_buff() prefers
sinfo->xdp_frags_truesize. The redirect-to-cpumap path does not.

If skb->truesize ends up below skb->len, socket rcvbuf and tcp_mem
accounting would be under-charged by a large factor. A remote sender
could exploit that to pin far more memory than the limits allow.

It would also trigger this warning when TCP coalesces into the
receive-queue tail via tcp_queue_rcv()->tcp_try_coalesce()->
skb_try_coalesce():

	if (WARN_ON_ONCE(delta < 0 || delta < len))
		return false;

Would it make sense to have __xdp_build_skb_from_frame() use
sinfo->xdp_frags_truesize? That field should still be valid, since
xdp_convert_buff_to_frame() does not touch it.

Alternatively, could frames with frags be kept off the redirect path
until the core accounts for them correctly?

>  	default:
>  		bpf_warn_invalid_xdp_action(nv->napi.dev, xdp_prog, act);
>  		fallthrough;
>  	case XDP_ABORTED:
> +xdp_exception:
>  		trace_xdp_exception(nv->napi.dev, xdp_prog, act);
>  		fallthrough;
>  	case XDP_DROP:

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203180924.3862144-1-bjorn%40kernel.org
Technical Details
Message-ID: <179640788740.3146.6062961675841789495@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377524-linux-kernel-netdev=dewy.ru
References: <20261203180924.3862144-1-bjorn@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377524-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2] eth: fbnic: Support XDP redirect
Date: Fri, 04 Dec 2026 18:11:27 +0000
Organization: Usenet Network
Message-ID: <179640788740.3146.6062961675841789495@kernel.org>
References: <20261203180924.3862144-1-bjorn@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2827396"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HMSSnxmCZAZWrPPzJYdVTfOHbHA= sha256:YhS+GBK25vLBfCjyLXKrYfR/eJORo75OPdjZx2F//8g=
	sha1:wh/6I8UeEci24arnMA1BnkPGrww= sha256:McaYisx40e1YbFl23kqo1jhwHh0YV6pK7AuUTCK4Mg4=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id DCA8F117C8B; Fri,  4 Dec 2026 21:11:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id O03hz6sXBKow;
	Fri,  4 Dec 2026 21:11:54 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377524-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 69487117C25; Fri,  4 Dec 2026 21:11:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 1F3CF60AD7D; Fri,  4 Dec 2026 18:11:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796407890;
	b=neWOVgzvp/f0qCXtCjaG4MydXlkr2yu0bv/3PrNeaqP9J24oOp3na4NQskPis0af4DHo
	 FjR8H0pg1DY0LUKVIq61J6mzlp7S1AZrZdtUyl8k1v/SICrrNKUGC8bYBrNTpghFnysX+
	 WBByi08RhR4c8p+mfDwSGk70iIEjoxnKL/2nAPxBcKvE0GUDXK2ZUKEDl1sys/cwZ0tqe
	 mOrGzSCcnFjT9GH4Q9uQwVhHAWuX3EKgv8wGSIDP0DtZfU2g1B1HOejhNlgFOGkWbRacG
	 gIW94CUOPxEBBozQ6b1vfztiWa2lG+ZdecEkwd3dbV14vdQTjynd74WyGvL8+IKej3A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796407890;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=KGulyHxoGGJDCDtfvobtYVUtyC+5DmaRRvBFSAcpbqs=;
	b=g1MFOhh94KgFC+4nh+pA8j+TTTHET8WZVo+4OC+KPhowF3TqhMlBN6InpWqW38hw7Us8
	 mIrHd3LiFcyJpH4ah8+XSk+F2o6u7tfJ8FT/FGObBS8Maag5HB4t6oBq11qO4ucCCTU45
	 1zAVYUs91ef9B6ZjQOogCGhPMP4rREBmLJWo6Xu03FMgtq1laJJmQKME3hxGGdtYWlN+I
	 4Yo7n0YLJRmydSrPh9wyZ0USn8XZ/LTuOLFftl1k1v0r/puCzRR9kcMIRBUBNi0Ho4u33
	 d2U92oL2eivRI+wvJTVUrxJgMVwZSvx8n/WDKrQimaGg2xZ/3FN26J8tHrsJ+7aAG9A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UVZAVUVR;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 94C4F606A68D;
	Fri,  4 Dec 2026 18:11:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UVZAVUVR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796407889;
	b=g8uqhaMxYEI+eoQPquelKWpDLe8HXidptK0tfQ9D8YGczs98MeCCComz6rvi/bU5zxDj
	 cCenVltAQ9CsCpQZBhdwZGLzVZhKQpo/BlAmN7ANTa2T7/FeOcj+G1BPfkA6KMpXKn4TX
	 ikdSTzYd1AiZEH47QpZLqibqkWsVjH3BI+kzCOf3nsbEwE15sBrdzydDSE/4ssoBrCzFf
	 VcK1mjZLr61+K4Tj/ZhtxlXPD5vtNv8Hw4tRWrbSZH4Q/643PDbscOiHonm0/NE1GaEWc
	 5Pe1WR4NlAdG0adKb+QmT2+jpkKCcrQfw3w0R1wFe577gxi0RU4DNUZEg4vMgDT5DcA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796407889;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=KGulyHxoGGJDCDtfvobtYVUtyC+5DmaRRvBFSAcpbqs=;
	b=H5TmQFUoiapcTZEJeWJm8sI/S+7JAYgMGk90LT0Cj7cyhAoIwGPlvCk819JssR/ZDfM5
	 vgAP84hmOlI/pxO1ojEQKLSSYobHoesMxtKGBpEvT0Acmtlh4figMuBg0dMrdXr/l0pSj
	 nS96hp4A01V2MZoF20fjA2n9Fauu36Kww3g64p9N+VD/2GNMcbsnKFxO6n+uqWA4T7iTO
	 Yupl/Bp0CxKV7kJ26kIBhjMEUgNFC6Cqlh3CD/faPnAYoMNqNhlfT4SooudItB7tNKEAj
	 N+6gxSm4OFDv6xtlulkBNaWi6VwA1fXY7jbGqhXwnMIqkpuLd/rdYG0zqOy9dYdvT8A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UVZAVUVR;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5CBD606A322;
	Fri,  4 Dec 2026 18:11:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6D0A1F00A13;
	Fri,  4 Dec 2026 18:11:27 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796407889;
	bh=KGulyHxoGGJDCDtfvobtYVUtyC+5DmaRRvBFSAcpbqs=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=UVZAVUVRndo7fOmhpEkTnfn7wBzgwddnDER1yFKRBIVEM7349Ymdhueb7KuG+si9M
	 H69v2BKqDwfcq+wjy0z45b5EYow/ZnBsmUkxh3Fb0mk1oFscJaUeEsYwZpNxuFk/6l
	 lDB/26Er9L/fPQI5wV1jBnFCwHvLJ0AiD6EYtCnFjArO+TH41YZzkAuSkSc9XvTicb
	 UuGpcu01XVOdJEhUPm4JdF/rNUI1GaqZZaDkoRL2OwhL43F/g1PCYqyQQOKtckM+uD
	 ZAfI99d7wT0nnbByL9FoNHELns8OI7UlapJyBNUnsfsCcMlTjIvSLYYkL+KfED16hJ
	 Kpu9wWjyZxW9Q==
X-Cc: alexanderduyck@fb.com, kuba@kernel.org, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, ast@kernel.org,
 daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
 willemb@google.com, netdev@vger.kernel.org, bpf@vger.kernel.org,
 kernel-team@meta.com, sdf@fomichev.me, horms@kernel.org,
 dimitri.daskalakis1@gmail.com, bobbyeshleman@meta.com, daniel.zahka@gmail.com,
 mike.marciniszyn@gmail.com, hmohsin@meta.com, leitao@debian.org
X-In-Reply-To: <20261203180924.3862144-1-bjorn@kernel.org>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list