From: netdev-bot+sashiko@kernel.org
To: antonio@mandelbit.com
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
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 [thread overview]
Message-ID: <179484275129.3136.12211553035452382830@kernel.org> (raw)
In-Reply-To: <20261112150612.3866546-3-antonio@mandelbit.com>
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
next prev parent reply other threads:[~2026-11-16 15:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 15:06 [PATCH net-next 0/3] tun: trim per-packet work on the write path Antonio Quartulli
2026-11-12 15:06 ` [PATCH net-next 1/3] tun: don't probe the transport header of packets written by userspace Antonio Quartulli
2026-11-16 15:25 ` netdev-bot+sashiko
2026-11-12 15:06 ` [PATCH net-next 2/3] tun: don't disable BHs for the XDP program check of every packet Antonio Quartulli
2026-11-13 15:06 ` sashiko-bot
2026-11-16 15:25 ` netdev-bot+sashiko [this message]
2026-11-12 15:06 ` [PATCH net-next 3/3] tun: skip the virtio-net header parsing without IFF_VNET_HDR Antonio Quartulli
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=179484275129.3136.12211553035452382830@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=antonio@mandelbit.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=jasowangio@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=willemdebruijn.kernel@gmail.com \
/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