Subject: Re: [PATCH net-next v2] ip_tunnel: Move stats update to iptunnel_xmit()

From: Nicolas Dichtel <[email-masked]>
Date: Thu, 24 Dec 2015 10:14:02 +0100

Le 24/12/2015 00:52, Pravin B Shelar a écrit :
[snip]
> @@ -83,22 +84,12 @@ int ip6_tnl_get_iflink(const struct net_device *dev);
>   static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
>   				  struct net_device *dev)
>   {
> -	struct net_device_stats *stats = &dev->stats;
>   	int pkt_len, err;
>
>   	pkt_len = skb->len - skb_inner_network_offset(skb);
>   	err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
> -
> -	if (net_xmit_eval(err) == 0) {
> -		struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
> -		u64_stats_update_begin(&tstats->syncp);
> -		tstats->tx_bytes += pkt_len;
> -		tstats->tx_packets++;
> -		u64_stats_update_end(&tstats->syncp);
> -		put_cpu_ptr(tstats);
> -	} else {
> -		stats->tx_errors++;
> -		stats->tx_aborted_errors++;
> -	}
> +	if (likely(!net_xmit_eval(err)))
> +		err = pkt_len;
> +	iptunnel_xmit_stats(dev, err);
I don't think this is an equivalent change.
For example, if err == NET_XMIT_DROP, then '!net_xmit_eval(err)' is false and
iptunnel_xmit_stats() is called with err set to a positive value (NET_XMIT_DROP
value is 0x01), ie not an error.