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 --- net/ipv4/ip_tunnel.c | 2 ++ net/ipv4/ip_tunnel_core.c | 2 +- net/ipv4/udp_tunnel_core.c | 3 +++ net/ipv6/sit.c | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 50d0f5fe4e4c..2136a46bcdc5 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..8a91f36cc052 100644 --- a/net/ipv4/udp_tunnel_core.c +++ b/net/ipv4/udp_tunnel_core.c @@ -190,8 +190,11 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb udp_set_csum(nocheck, skb, src, dst, skb->len); + rcu_read_lock(); iptunnel_xmit(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, xnet, ipcb_flags); + rcu_read_unlock(); + ip_rt_put(rt); } EXPORT_SYMBOL_GPL(udp_tunnel_xmit_skb); diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index ef2e5111fb3a..34d4d72dc58a 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -1029,6 +1029,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