]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ip_tunnel: allow not to count pkts on tstats by setting skb's dev to NULL
authorXin Long <lucien.xin@gmail.com>
Mon, 17 Jun 2019 13:34:13 +0000 (21:34 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Jun 2019 00:48:45 +0000 (20:48 -0400)
iptunnel_xmit() works as a common function, also used by a udp tunnel
which doesn't have to have a tunnel device, like how TIPC works with
udp media.

In these cases, we should allow not to count pkts on dev's tstats, so
that udp tunnel can work with no tunnel device safely.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_tunnel_core.c

index 9e3846388fb3c0959ce06a1da8b9e3821b0ab5fe..1452a97914a0d7e81e558d1137a45878e01a89af 100644 (file)
@@ -76,9 +76,12 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
        __ip_select_ident(net, iph, skb_shinfo(skb)->gso_segs ?: 1);
 
        err = ip_local_out(net, sk, skb);
-       if (unlikely(net_xmit_eval(err)))
-               pkt_len = 0;
-       iptunnel_xmit_stats(dev, pkt_len);
+
+       if (dev) {
+               if (unlikely(net_xmit_eval(err)))
+                       pkt_len = 0;
+               iptunnel_xmit_stats(dev, pkt_len);
+       }
 }
 EXPORT_SYMBOL_GPL(iptunnel_xmit);