From: Jakub Kicinski <kuba@kernel.org>
To: mmietus97@yahoo.com
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Jason@zx2c4.com, sd@queasysnail.net
Subject: Re: [net-next,v6,04/11] net: tunnel: allow noref dsts in udp_tunnel{,6}_dst_lookup
Date: Wed, 21 Jan 2026 18:21:06 -0800 [thread overview]
Message-ID: <20260122022106.2528669-1-kuba@kernel.org> (raw)
In-Reply-To: <20260120162451.23512-5-mmietus97@yahoo.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: tunnel: allow noref dsts in udp_tunnel{,6}_dst_lookup
This commit updates udp_tunnel{,6}_dst_lookup to return noref dsts when
possible. All callers are updated to properly use the new noref argument
and conditionally release the dst based on whether they own a reference.
> diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
> index 92ee4a36f86f..1aa3d5d74a84 100644
> --- a/drivers/net/bareudp.c
> +++ b/drivers/net/bareudp.c
> @@ -315,6 +315,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> int min_headroom;
> __u8 tos, ttl;
> __be32 saddr;
> + bool noref;
> int err;
[ ... ]
> @@ -329,7 +330,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> rt = udp_tunnel_dst_lookup(skb, dev, bareudp->net, 0, &saddr, &info->key,
> sport, bareudp->port, key->tos,
> use_cache ?
> - (struct dst_cache *)&info->dst_cache : NULL);
> + (struct dst_cache *)&info->dst_cache : NULL,
> + &noref);
[ ... ]
> @@ -364,7 +366,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> !net_eq(bareudp->net, dev_net(bareudp->dev)),
> !test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags),
> 0);
> - ip_rt_put(rt);
> + if (!noref)
> + ip_rt_put(rt);
> return 0;
>
> free_dst:
> dst_release(&rt->dst);
^^^^^^^^^^^^^^^^^^^^
The success path above correctly checks if (!noref) before calling
ip_rt_put(), but the free_dst error path still unconditionally calls
dst_release(). When the dst comes from the cache (noref == true) and an
error occurs in the operations between the lookup and xmit, this would
decrement a refcount we do not own.
For comparison, bareudp6_xmit_skb() in this same patch correctly wraps
both its success and error paths with if (!noref) checks:
> @@ -434,11 +439,13 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> !test_bit(IP_TUNNEL_CSUM_BIT,
> info->key.tun_flags),
> 0);
> - dst_release(dst);
> + if (!noref)
> + dst_release(dst);
> return 0;
>
> free_dst:
> - dst_release(dst);
> + if (!noref)
> + dst_release(dst);
> return err;
Should the free_dst label in bareudp_xmit_skb() also be wrapped with
if (!noref)?
next prev parent reply other threads:[~2026-01-22 2:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260120162451.23512-1-mmietus97.ref@yahoo.com>
2026-01-20 16:24 ` [PATCH net-next v6 00/11] net: tunnel: introduce noref xmit flows for tunnels Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 01/11] net: dst_cache: add noref versions for dst_cache Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 02/11] net: tunnel: convert iptunnel_xmit to noref Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 03/11] net: tunnel: convert udp_tunnel{6,}_xmit_skb " Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 04/11] net: tunnel: allow noref dsts in udp_tunnel{,6}_dst_lookup Marek Mietus
2026-01-22 2:21 ` Jakub Kicinski [this message]
2026-01-20 16:24 ` [PATCH net-next v6 05/11] net: ovpn: convert ovpn_udp{4,6}_output to use a noref dst Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 06/11] wireguard: socket: convert send{4,6} to use a noref dst when possible Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 07/11] net: tunnel: convert ip_md_tunnel_xmit " Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 08/11] net: tunnel: convert ip_tunnel_xmit " Marek Mietus
2026-01-20 16:24 ` [PATCH net-next v6 09/11] net: sctp: convert sctp_v{4,6}_xmit " Marek Mietus
2026-01-22 2:20 ` Jakub Kicinski
2026-01-20 16:24 ` [PATCH net-next v6 10/11] net: sit: convert ipip6_tunnel_xmit to use a noref dst Marek Mietus
2026-01-20 16:33 ` [PATCH net-next v6 11/11] net: tipc: convert tipc_udp_xmit " Marek Mietus
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=20260122022106.2528669-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=Jason@zx2c4.com \
--cc=mmietus97@yahoo.com \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
/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