public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Marek Mietus <mmietus97@yahoo.com>
To: netdev@vger.kernel.org, sd@queasysnail.net, kuba@kernel.org
Cc: Jason@zx2c4.com, Marek Mietus <mmietus97@yahoo.com>
Subject: [PATCH net-next v5 02/11] net: tunnel: convert iptunnel_xmit to noref
Date: Tue, 13 Jan 2026 17:29:45 +0100	[thread overview]
Message-ID: <20260113162954.5948-3-mmietus97@yahoo.com> (raw)
In-Reply-To: <20260113162954.5948-1-mmietus97@yahoo.com>

iptunnel_xmit assumes that a reference was taken on the dst passed to it,
and uses that reference.

This forces callers to reference the dst, preventing noref optimizations.

Convert iptunnel_xmit to be noref and drop the requirement that a ref be
taken on the dst.

Signed-off-by: Marek Mietus <mmietus97@yahoo.com>
---
 net/ipv4/ip_tunnel.c       | 2 ++
 net/ipv4/ip_tunnel_core.c  | 2 +-
 net/ipv4/udp_tunnel_core.c | 1 +
 net/ipv6/sit.c             | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 158a30ae7c5f..8a0c611ab1bf 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -655,6 +655,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, proto, tos, ttl,
 		      df, !net_eq(tunnel->net, dev_net(dev)), 0);
+	ip_rt_put(rt);
 	return;
 tx_error:
 	DEV_STATS_INC(dev, tx_errors);
@@ -844,6 +845,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
 		      df, !net_eq(tunnel->net, dev_net(dev)), 0);
+	ip_rt_put(rt);
 	return;
 
 #if IS_ENABLED(CONFIG_IPV6)
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 2e61ac137128..70f0f123b0ba 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -61,7 +61,7 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
 	skb_scrub_packet(skb, xnet);
 
 	skb_clear_hash_if_not_l4(skb);
-	skb_dst_set(skb, &rt->dst);
+	skb_dst_set_noref(skb, &rt->dst);
 	memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
 	IPCB(skb)->flags = ipcb_flags;
 
diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c
index b1f667c52cb2..a34066d91375 100644
--- a/net/ipv4/udp_tunnel_core.c
+++ b/net/ipv4/udp_tunnel_core.c
@@ -192,6 +192,7 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb
 
 	iptunnel_xmit(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, xnet,
 		      ipcb_flags);
+	ip_rt_put(rt);
 }
 EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb);
 
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index cf37ad9686e6..a0d699082747 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1028,6 +1028,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
 
 	iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
 		      df, !net_eq(tunnel->net, dev_net(dev)), 0);
+	ip_rt_put(rt);
 	return NETDEV_TX_OK;
 
 tx_error_icmp:
-- 
2.51.0


  parent reply	other threads:[~2026-01-13 16:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260113162954.5948-1-mmietus97.ref@yahoo.com>
2026-01-13 16:29 ` [PATCH net-next v5 00/11] net: tunnel: introduce noref xmit flows for tunnels Marek Mietus
2026-01-13 16:29   ` [PATCH net-next v5 01/11] net: dst_cache: add noref versions for dst_cache Marek Mietus
2026-01-13 16:29   ` Marek Mietus [this message]
2026-01-13 16:29   ` [PATCH net-next v5 03/11] net: tunnel: convert udp_tunnel{6,}_xmit_skb to noref Marek Mietus
2026-01-18  0:36     ` [net-next,v5,03/11] " Jakub Kicinski
2026-01-20 13:25       ` Marek Mietus
2026-01-13 16:29   ` [PATCH net-next v5 04/11] net: tunnel: allow noref dsts in udp_tunnel{,6}_dst_lookup Marek Mietus
2026-01-13 16:29   ` [PATCH net-next v5 05/11] net: ovpn: convert ovpn_udp{4,6}_output to use a noref dst Marek Mietus
2026-01-13 16:29   ` [PATCH net-next v5 06/11] wireguard: socket: convert send{4,6} to use a noref dst when possible Marek Mietus
2026-01-13 16:29   ` [PATCH net-next v5 07/11] net: tunnel: convert ip_md_tunnel_xmit " Marek Mietus
2026-01-13 16:29   ` [PATCH net-next v5 08/11] net: tunnel: convert ip_tunnel_xmit " Marek Mietus
2026-01-13 16:36   ` [PATCH net-next v5 09/11] net: sctp: convert sctp_v{4,6}_xmit " Marek Mietus
2026-01-18  0:36     ` [net-next,v5,09/11] " Jakub Kicinski
2026-01-13 16:36   ` [PATCH net-next v5 10/11] net: sit: convert ipip6_tunnel_xmit to use a noref dst Marek Mietus
2026-01-18  0:36     ` [net-next,v5,10/11] " Jakub Kicinski
2026-01-13 16:36   ` [PATCH net-next v5 11/11] net: tipc: convert tipc_udp_xmit " Marek Mietus
2026-03-17 11:02   ` [PATCH net-next v5 00/11] net: tunnel: introduce noref xmit flows for tunnels Paolo Abeni
2026-03-17 11:28     ` Sabrina Dubroca

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=20260113162954.5948-3-mmietus97@yahoo.com \
    --to=mmietus97@yahoo.com \
    --cc=Jason@zx2c4.com \
    --cc=kuba@kernel.org \
    --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