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 v7 11/11] net: tipc: convert tipc_udp_xmit to use a noref dst
Date: Tue, 27 Jan 2026 08:04:52 +0100	[thread overview]
Message-ID: <20260127070452.6581-12-mmietus97@yahoo.com> (raw)
In-Reply-To: <20260127070452.6581-1-mmietus97@yahoo.com>

tipc_udp_xmit unnecessarily references the dst_entry from the
dst_cache when interacting with the cache.

Reduce this overhead by avoiding the redundant refcount increments.

This change is safe as both ipv4 and ip6 support noref xmit under RCU
which is already the case for tipc_udp_xmit.

Signed-off-by: Marek Mietus <mmietus97@yahoo.com>
---
 net/tipc/udp_media.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index ba4ff5b3354f..cc1ef043aaf0 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -175,7 +175,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
 	int ttl, err;
 
 	local_bh_disable();
-	ndst = dst_cache_get(cache);
+	ndst = dst_cache_get_rcu(cache);
 	if (dst->proto == htons(ETH_P_IP)) {
 		struct rtable *rt = dst_rtable(ndst);
 
@@ -191,14 +191,13 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
 				err = PTR_ERR(rt);
 				goto tx_error;
 			}
-			dst_cache_set_ip4(cache, &rt->dst, fl.saddr);
+			dst_cache_steal_ip4(cache, &rt->dst, fl.saddr);
 		}
 
 		ttl = ip4_dst_hoplimit(&rt->dst);
 		udp_tunnel_xmit_skb(rt, ub->ubsock->sk, skb, src->ipv4.s_addr,
 				    dst->ipv4.s_addr, 0, ttl, 0, src->port,
 				    dst->port, false, true, 0);
-		ip_rt_put(rt);
 #if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		if (!ndst) {
@@ -215,13 +214,12 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
 				err = PTR_ERR(ndst);
 				goto tx_error;
 			}
-			dst_cache_set_ip6(cache, ndst, &fl6.saddr);
+			dst_cache_steal_ip6(cache, ndst, &fl6.saddr);
 		}
 		ttl = ip6_dst_hoplimit(ndst);
 		udp_tunnel6_xmit_skb(ndst, ub->ubsock->sk, skb, NULL,
 				     &src->ipv6, &dst->ipv6, 0, ttl, 0,
 				     src->port, dst->port, false, 0);
-		dst_release(ndst);
 #endif
 	}
 	local_bh_enable();
-- 
2.51.0


  parent reply	other threads:[~2026-01-27  7:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260127070452.6581-1-mmietus97.ref@yahoo.com>
2026-01-27  7:04 ` [PATCH net-next v7 00/11] net: tunnel: introduce noref xmit flows for tunnels Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 01/11] net: dst_cache: add noref versions for dst_cache Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 02/11] net: tunnel: convert iptunnel_xmit to noref Marek Mietus
2026-02-03  8:21     ` Paolo Abeni
2026-02-04 16:52       ` Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 03/11] net: tunnel: convert udp_tunnel{6,}_xmit_skb " Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 04/11] net: tunnel: allow noref dsts in udp_tunnel{,6}_dst_lookup Marek Mietus
2026-01-30  0:56     ` Sabrina Dubroca
2026-01-27  7:04   ` [PATCH net-next v7 05/11] net: ovpn: convert ovpn_udp{4,6}_output to use a noref dst Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 06/11] wireguard: socket: convert send{4,6} to use a noref dst when possible Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 07/11] net: tunnel: convert ip_md_tunnel_xmit " Marek Mietus
2026-02-03  8:27     ` Paolo Abeni
2026-01-27  7:04   ` [PATCH net-next v7 08/11] net: tunnel: convert ip_tunnel_xmit " Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 09/11] net: sctp: convert sctp_v{4,6}_xmit " Marek Mietus
2026-01-27  7:04   ` [PATCH net-next v7 10/11] net: sit: convert ipip6_tunnel_xmit to use a noref dst Marek Mietus
2026-01-27  7:04   ` Marek Mietus [this message]
2026-02-03  8:32   ` [PATCH net-next v7 00/11] net: tunnel: introduce noref xmit flows for tunnels Paolo Abeni
2026-02-12 14:47     ` 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=20260127070452.6581-12-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