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 v6 03/11] net: tunnel: convert udp_tunnel{6,}_xmit_skb to noref
Date: Tue, 20 Jan 2026 17:24:43 +0100 [thread overview]
Message-ID: <20260120162451.23512-4-mmietus97@yahoo.com> (raw)
In-Reply-To: <20260120162451.23512-1-mmietus97@yahoo.com>
udp_tunnel{6,}_xmit_skb assume that a reference was taken on the dst
passed to them, and use that reference.
This forces callers to reference the dst, preventing noref optimizations.
Convert udp_tunnel{6,}_xmit_skb to be noref and drop the requirement
that a ref be taken on the dst.
Signed-off-by: Marek Mietus <mmietus97@yahoo.com>
---
drivers/net/amt.c | 3 +++
drivers/net/bareudp.c | 2 ++
drivers/net/geneve.c | 2 ++
drivers/net/gtp.c | 5 +++++
drivers/net/ovpn/udp.c | 2 ++
drivers/net/vxlan/vxlan_core.c | 2 ++
drivers/net/wireguard/socket.c | 2 ++
net/ipv4/udp_tunnel_core.c | 1 -
net/ipv6/ip6_udp_tunnel.c | 2 +-
net/sctp/ipv6.c | 1 +
net/sctp/protocol.c | 1 +
net/tipc/udp_media.c | 2 ++
12 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/net/amt.c b/drivers/net/amt.c
index 902c817a0dea..e9eeaa7b6fe7 100644
--- a/drivers/net/amt.c
+++ b/drivers/net/amt.c
@@ -1050,6 +1050,7 @@ static bool amt_send_membership_update(struct amt_dev *amt,
false,
false,
0);
+ ip_rt_put(rt);
amt_update_gw_status(amt, AMT_STATUS_SENT_UPDATE, true);
return false;
}
@@ -1108,6 +1109,7 @@ static void amt_send_multicast_data(struct amt_dev *amt,
false,
false,
0);
+ ip_rt_put(rt);
}
static bool amt_send_membership_query(struct amt_dev *amt,
@@ -1167,6 +1169,7 @@ static bool amt_send_membership_query(struct amt_dev *amt,
false,
false,
0);
+ ip_rt_put(rt);
amt_update_relay_status(tunnel, AMT_STATUS_SENT_QUERY, true);
return false;
}
diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
index 0df3208783ad..92ee4a36f86f 100644
--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -364,6 +364,7 @@ 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);
return 0;
free_dst:
@@ -433,6 +434,7 @@ 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);
return 0;
free_dst:
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 77b0c3d52041..169a2b7d83e0 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -926,6 +926,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
!net_eq(geneve->net, dev_net(geneve->dev)),
!test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags),
0);
+ ip_rt_put(rt);
return 0;
}
@@ -1019,6 +1020,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
!test_bit(IP_TUNNEL_CSUM_BIT,
info->key.tun_flags),
0);
+ dst_release(dst);
return 0;
}
#endif
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 4213c3b2d532..3cd1f16136a3 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -449,6 +449,7 @@ static int gtp0_send_echo_resp_ip(struct gtp_dev *gtp, struct sk_buff *skb)
dev_net(gtp->dev)),
false,
0);
+ ip_rt_put(rt);
return 0;
}
@@ -708,6 +709,7 @@ static int gtp1u_send_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb)
dev_net(gtp->dev)),
false,
0);
+ ip_rt_put(rt);
return 0;
}
@@ -1308,6 +1310,7 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)
!net_eq(sock_net(pktinfo.pctx->sk),
dev_net(dev)),
false, 0);
+ ip_rt_put(pktinfo.rt);
break;
case AF_INET6:
#if IS_ENABLED(CONFIG_IPV6)
@@ -1318,6 +1321,7 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)
0,
pktinfo.gtph_port, pktinfo.gtph_port,
false, 0);
+ dst_release(&pktinfo.rt6->dst);
#else
goto tx_err;
#endif
@@ -2409,6 +2413,7 @@ static int gtp_genl_send_echo_req(struct sk_buff *skb, struct genl_info *info)
!net_eq(sock_net(sk),
dev_net(gtp->dev)),
false, 0);
+ ip_rt_put(rt);
return 0;
}
diff --git a/drivers/net/ovpn/udp.c b/drivers/net/ovpn/udp.c
index d6a0f7a0b75d..c82ba71b6aff 100644
--- a/drivers/net/ovpn/udp.c
+++ b/drivers/net/ovpn/udp.c
@@ -200,6 +200,7 @@ static int ovpn_udp4_output(struct ovpn_peer *peer, struct ovpn_bind *bind,
udp_tunnel_xmit_skb(rt, sk, skb, fl.saddr, fl.daddr, 0,
ip4_dst_hoplimit(&rt->dst), 0, fl.fl4_sport,
fl.fl4_dport, false, sk->sk_no_check_tx, 0);
+ ip_rt_put(rt);
ret = 0;
err:
local_bh_enable();
@@ -275,6 +276,7 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind,
udp_tunnel6_xmit_skb(dst, sk, skb, skb->dev, &fl.saddr, &fl.daddr, 0,
ip6_dst_hoplimit(dst), 0, fl.fl6_sport,
fl.fl6_dport, udp_get_no_check6_tx(sk), 0);
+ dst_release(dst);
ret = 0;
err:
local_bh_enable();
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index e957aa12a8a4..09ddf0586176 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2538,6 +2538,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
pkey->u.ipv4.dst, tos, ttl, df,
src_port, dst_port, xnet, !udp_sum,
ipcb_flags);
+ ip_rt_put(rt);
#if IS_ENABLED(CONFIG_IPV6)
} else {
struct vxlan_sock *sock6;
@@ -2613,6 +2614,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
&saddr, &pkey->u.ipv6.dst, tos, ttl,
pkey->label, src_port, dst_port, !udp_sum,
ip6cb_flags);
+ dst_release(ndst);
#endif
}
vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX, pkt_len);
diff --git a/drivers/net/wireguard/socket.c b/drivers/net/wireguard/socket.c
index 253488f8c00f..ee7d9c675909 100644
--- a/drivers/net/wireguard/socket.c
+++ b/drivers/net/wireguard/socket.c
@@ -85,6 +85,7 @@ static int send4(struct wg_device *wg, struct sk_buff *skb,
udp_tunnel_xmit_skb(rt, sock, skb, fl.saddr, fl.daddr, ds,
ip4_dst_hoplimit(&rt->dst), 0, fl.fl4_sport,
fl.fl4_dport, false, false, 0);
+ ip_rt_put(rt);
goto out;
err:
@@ -152,6 +153,7 @@ static int send6(struct wg_device *wg, struct sk_buff *skb,
udp_tunnel6_xmit_skb(dst, sock, skb, skb->dev, &fl.saddr, &fl.daddr, ds,
ip6_dst_hoplimit(dst), 0, fl.fl6_sport,
fl.fl6_dport, false, 0);
+ dst_release(dst);
goto out;
err:
diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c
index a34066d91375..b1f667c52cb2 100644
--- a/net/ipv4/udp_tunnel_core.c
+++ b/net/ipv4/udp_tunnel_core.c
@@ -192,7 +192,6 @@ 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/ip6_udp_tunnel.c b/net/ipv6/ip6_udp_tunnel.c
index cef3e0210744..d58815db8182 100644
--- a/net/ipv6/ip6_udp_tunnel.c
+++ b/net/ipv6/ip6_udp_tunnel.c
@@ -95,7 +95,7 @@ void udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
uh->len = htons(skb->len);
- skb_dst_set(skb, dst);
+ skb_dst_set_noref(skb, dst);
udp6_set_csum(nocheck, skb, saddr, daddr, skb->len);
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 531cb0690007..38fd1cf3148f 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -264,6 +264,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *t)
udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr, &fl6->daddr,
tclass, ip6_dst_hoplimit(dst), label,
sctp_sk(sk)->udp_port, t->encap_port, false, 0);
+ dst_release(dst);
return 0;
}
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2c3398f75d76..ff18ed0a65ff 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1074,6 +1074,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, struct sctp_transport *t)
fl4->daddr, dscp, ip4_dst_hoplimit(dst), df,
sctp_sk(sk)->udp_port, t->encap_port, false, false,
0);
+ dst_release(dst);
return 0;
}
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index b85ab0fb3b8c..ba4ff5b3354f 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -198,6 +198,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
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) {
@@ -220,6 +221,7 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
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
next prev parent reply other threads:[~2026-01-20 16:26 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 ` Marek Mietus [this message]
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 ` [net-next,v6,04/11] " Jakub Kicinski
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=20260120162451.23512-4-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