๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17291

Re: [PATCH net-next 2/3] tun: don't disable BHs for the XDP program check of every packet

#17291
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 15:25
73 lines
10250 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In drivers/net/tun.c, the patch adds a function-scope `bool xdp`
  to tun_build_skb() (line 1705).

--

tun: don't disable BHs for the XDP program check of every packet

The patch removes the RCU/BH-disabled section that tun_get_user() and
tun_build_skb() entered for every packet just to check for an attached
XDP program. It checks first with rcu_access_pointer(), and only enters
the BH-disabled RCU section when a program is attached.

> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 9fc60a73fb963..395923651f312 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1702,13 +1702,12 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
>  	int pad = TUN_RX_PAD;
>  	int metasize = 0;
>  	int err = 0;
> +	bool xdp;
>  
> -	rcu_read_lock();
> -	xdp_prog = rcu_dereference(tun->xdp_prog);
> -	if (xdp_prog)
> +	xdp = rcu_access_pointer(tun->xdp_prog);
> +	if (xdp)

[Severity: Low]
This isn't a bug, but the new function-scope bool xdp in tun_build_skb()
is shadowed by an existing variable of the same name further down in the
same function:

drivers/net/tun.c:tun_build_skb() {
    ...
	xdp_prog = rcu_dereference(tun->xdp_prog);
	if (xdp_prog) {
		struct xdp_buff xdp;
		u32 act;

		xdp_init_buff(&xdp, buflen, &tfile->xdp_rxq);
		xdp_prepare_buff(&xdp, buf, pad, len, true);
    ...
}

The bool is only read before that block, so the behavior is correct.
However, the function now has two unrelated xdp identifiers of different
types, which gives a -Wshadow warning with W=2. It may also confuse
anyone editing the XDP block later.

Before this patch the gate reused xdp_prog, so there was no clash.

Could the bool get a different name, for example has_xdp or
xdp_attached?

The later patches in the series leave this unchanged. Both declarations
are still present at the end of the series (5b2d3d96af5d).

>  		pad += XDP_PACKET_HEADROOM;
>  	buflen += SKB_DATA_ALIGN(len + pad);
> -	rcu_read_unlock();

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112150612.3866546-1-antonio%40mandelbit.com
Technical Details
Message-ID: <179484275129.3136.12211553035452382830@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364501-linux-kernel-netdev=dewy.ru
References: <20261112150612.3866546-3-antonio@mandelbit.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364501-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 2/3] tun: don't disable BHs for the XDP program
 check of every packet
Date: Mon, 16 Nov 2026 15:25:51 +0000
Organization: Usenet Network
Message-ID: <179484275129.3136.12211553035452382830@kernel.org>
References: <20261112150612.3866546-3-antonio@mandelbit.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2098621"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:RW8TrqOPs2a8YXBXaB0TxKQDBko= sha256:v03GPGaHDxSJKGhoq0AuskaGfQLsjDkY2eBplzSHRPc=
	sha1:aOl69b6lLpDqybAY1LayFueFImo= sha256:0QKWph8oAPxiXUE2ozkzipV5e9KONH1k0xF7VCcEFPM=
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 D3365114CAB; Mon, 16 Nov 2026 18:27:07 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 BWTww7_QCzlV;
	Mon, 16 Nov 2026 18:27:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364501-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 26DD2114CAD; Mon, 16 Nov 2026 18:26:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 92EC82F0F5; Mon, 16 Nov 2026 15:25:59 +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=1794842753;
	b=RKvBhtan4vpUwoOQgz0RqQkN5QGjhN97OcvfpM+ej1JV1LXaksBqsBlPRKDi4EteKOms
	 +xi/ghY+hdOHmp91KL6ZSWS1PwaZc8D4vwELlVTvLlw0IsfAVVnu406CgahNyjqjXZya7
	 stCB2ukeRh8xG1eKLyQEJmgSdeny+0l20QWvVN8H1MUkGThpQ5L+z2dy6wlFoJj3SlBnJ
	 HjW3JWhK+vZqoPBUiHkA9xt3hYjU6Q6MKvHZiDaN1gCuRdgMfQ0RTgGUlonEEb3qO4mCd
	 t8GO4OOFlz9SFae7AlX+lte9t6crAwFESBU3xPb8Oe7MzUNEE8nwtAgmUifUaZPM8Jw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794842753;
	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=CxECcGoxG4bJHUkxZ78akWi3QF20UqitrJenE+Sv7pU=;
	b=KxaP0RnuMSWHpHj8VJwUfC3k8sY45yqxUYdezDYTBV4+yVVubJL5YKv0J60QZEERLowM
	 SpoH7mhNYTiTsG69GVGEGKozhXuxJK3EwHo95oyfBi3Kt5FyjjJ1ZnIVQu/pzdUwFNNu3
	 FiQ45XeeMlcN31mkFCOH4ICOrQ7f384tHKQLpQ7UocczbBFr8ldqO/SVXIFxqDb+m4oWN
	 85AV+0xFKo6ezSf2dxUyqcFm4BXb1STrYrxzsZNF9WPOp+EhX3392C+x9Tm2hLhklWwV8
	 GTvKynSTmiOUXqGnt5zsDJEjEJ9YFKE5TcZsxcvY5RrgAiEK86UMqFYYc1rffgJ8HFQ==
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=Qs+5J6Rd;
	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 A79B7606A88D;
	Mon, 16 Nov 2026 15:25:53 +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=Qs+5J6Rd
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=1794842752;
	b=Wnlr4aPgEA8nLJt3za3Y92v/C6M48DiGABNFeu0/iuoB/Sx63sH/nX24TBayCrWLWAdg
	 qsmC+dPb4KBE06IatZvH/mAm52ofmbMIfRL5eAwbrtt2yNcBPgE8gxR0hfeEGwVB9Qj9R
	 k+zo8Rs0lco3lTwpaN/xBoGMWUESd5nKTYXkngUIZY6/jzY9ryVJyqvl68Ywjp3YNYOHf
	 xrUckfLIV+HpTRz7cKs8pP5m8TLfruj309WnWxkDoPQ5Dd3q2ZJDRvl4tskaXO72pMfN0
	 a0778Ebg0IFQerEoykzFyIt/QI7MPAUmlxyt9eXqYeQXHqC9PhC9UG9KHQ6nx5ysYTQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794842752;
	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=CxECcGoxG4bJHUkxZ78akWi3QF20UqitrJenE+Sv7pU=;
	b=TRbsZs3hc2AOe5AZJ4zEbW9IC0fmJApgOE9YAZZxZ3hmKM66j9ZAzN9HcIAUW/CK56zC
	 7KOEibv3tJroQnufXcDnXyzqplttBXV/1VAzX2AOEHxfjhdzC8nUPQuuT9xl5jtG/Nkj5
	 0C0ykQuUHKM4JLbFZ59o0oC5vU3r24Jelhq91KoufopDQvG8+lcqpHSSwN7bp5Yzqcg9+
	 bijPX+t5y2Qq2YmxsQvHBWFGBwoVCMzR7IXU1MRVCH5BJRhSpgf30BWc0bWLYXpSz1Q+J
	 hMEjrRFhvChYu+w3heX39OF0JjbkF/tQgsMr/8CAD6s8un8DdEknqnghozmMOwu3CDw==
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=Qs+5J6Rd;
	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 BEB63606A8A4;
	Mon, 16 Nov 2026 15:25:52 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B56911F000C7;
	Mon, 16 Nov 2026 15:25:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794842752;
	bh=CxECcGoxG4bJHUkxZ78akWi3QF20UqitrJenE+Sv7pU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Qs+5J6Rd9BZbhbHnL22oXoUQCFp6iG5stidvs2j647DC2P6eXFadypiq38Q3D3XVW
	 BJuSM7e/oehj6rkuwdt9vMD6hL7JGS0btpUBzuWxsWKkV0v4SYDtuTYMFdoaRpnla+
	 g3TmbRvXZxt/myK1BAzTP9AF/3dAFWlRaM4bpsAul8hFUYUkEfDTI22T/MAPpF8BnT
	 /DEs6hc8wNqhrydfvnrVfzhPu6N+CjKART2xll5e0r/G4nnFTyCqFLpiBF8I0zs4WK
	 Qod7lXTDRzmBJnEI3T6izL52TK0ptuOZ9n+werwflVKWAwXqraG52XrU6o1IcVSGjx
	 M9ZioekCFC/Lg==
X-Cc: willemdebruijn.kernel@gmail.com, jasowangio@gmail.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net,
 hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me,
 netdev@vger.kernel.org, bpf@vger.kernel.org
X-In-Reply-To: <20261112150612.3866546-3-antonio@mandelbit.com>
X-sashiko-severity: Low
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