[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251112073324.5301-4-mmietus97@yahoo.com>
Date: Wed, 12 Nov 2025 08:33:23 +0100
From: Marek Mietus <mmietus97@...oo.com>
To: netdev@...r.kernel.org,
sd@...asysnail.net,
kuba@...nel.org
Cc: Marek Mietus <mmietus97@...oo.com>
Subject: [PATCH net-next v4 13/14] net: tipc: convert tipc_udp_xmit to use a noref dst
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@...oo.com>
---
net/tipc/udp_media.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index 8e165b219863..2a6c4df0c0a8 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,13 +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(dst_to_dstref(&rt->dst), ub->ubsock->sk, skb, src->ipv4.s_addr,
- dst->ipv4.s_addr, 0, ttl, 0, src->port,
- dst->port, false, true, 0);
+ udp_tunnel_xmit_skb(dst_to_dstref_noref(&rt->dst), ub->ubsock->sk, skb,
+ src->ipv4.s_addr, dst->ipv4.s_addr, 0, ttl, 0,
+ src->port, dst->port, false, true, 0);
#if IS_ENABLED(CONFIG_IPV6)
} else {
if (!ndst) {
@@ -214,10 +214,10 @@ 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(dst_to_dstref(ndst), ub->ubsock->sk, skb, NULL,
+ udp_tunnel6_xmit_skb(dst_to_dstref_noref(ndst), ub->ubsock->sk, skb, NULL,
&src->ipv6, &dst->ipv6, 0, ttl, 0,
src->port, dst->port, false, 0);
#endif
--
2.51.0
Powered by blists - more mailing lists