public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tobias Klauser <tklauser@distanz.ch>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] slip: Use net_device_stats from struct net_device
Date: Thu, 19 Aug 2010 10:49:51 +0200	[thread overview]
Message-ID: <1282207791.2549.16.camel@edumazet-laptop> (raw)
In-Reply-To: <1282206313-10667-1-git-send-email-tklauser@distanz.ch>

Le jeudi 19 août 2010 à 10:25 +0200, Tobias Klauser a écrit :
> Use net_device->stats for stats instead of private variable copies in
> struct slip.
> 
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
>  drivers/net/slip.c |   64 ++++++++++++++++++++++------------------------------
>  drivers/net/slip.h |    9 -------
>  2 files changed, 27 insertions(+), 46 deletions(-)


> @@ -561,36 +562,25 @@ static int sl_change_mtu(struct net_device *dev, int new_mtu)
>  static struct net_device_stats *
>  sl_get_stats(struct net_device *dev)
>  {
> -	static struct net_device_stats stats;
> +	struct net_device_stats *stats = &dev->stats;
>  	struct slip *sl = netdev_priv(dev);
>  #ifdef SL_INCLUDE_CSLIP
>  	struct slcompress *comp;
>  #endif
>  
> -	memset(&stats, 0, sizeof(struct net_device_stats));
> -
> -	stats.rx_packets     = sl->rx_packets;
> -	stats.tx_packets     = sl->tx_packets;
> -	stats.rx_bytes	     = sl->rx_bytes;
> -	stats.tx_bytes	     = sl->tx_bytes;
> -	stats.rx_dropped     = sl->rx_dropped;
> -	stats.tx_dropped     = sl->tx_dropped;
> -	stats.tx_errors      = sl->tx_errors;
> -	stats.rx_errors      = sl->rx_errors;
> -	stats.rx_over_errors = sl->rx_over_errors;
>  #ifdef SL_INCLUDE_CSLIP
> -	stats.rx_fifo_errors = sl->rx_compressed;
> -	stats.tx_fifo_errors = sl->tx_compressed;
> -	stats.collisions     = sl->tx_misses;
> +	stats->rx_fifo_errors = sl->rx_compressed;
> +	stats->tx_fifo_errors = sl->tx_compressed;
> +	stats->collisions     = sl->tx_misses;
>  	comp = sl->slcomp;
>  	if (comp) {
> -		stats.rx_fifo_errors += comp->sls_i_compressed;
> -		stats.rx_dropped     += comp->sls_i_tossed;
> -		stats.tx_fifo_errors += comp->sls_o_compressed;
> -		stats.collisions     += comp->sls_o_misses;
> +		stats->rx_fifo_errors += comp->sls_i_compressed;
> +		stats->rx_dropped     += comp->sls_i_tossed;
> +		stats->tx_fifo_errors += comp->sls_o_compressed;
> +		stats->collisions     += comp->sls_o_misses;
>  	}
> -#endif /* CONFIG_INET */
> -	return (&stats);
> +#endif
> +	return stats;
>  }
>  

Hmm, this is wrong.

Each time sl_get_stats() is called, you are adding stuff to dev->stats

Quite frankly I dont think its a kernel-janitors@vger.kernel.org patch,
its pretty normal netdev stuff.

Please take a look at prior patch posted yesterday.

http://marc.info/?l=linux-netdev&m=128213719605250&w=2

Because either you should build your patch on top of it, or ask David to
revert mine before ;)

I advise using a ndo_get_stats64() so that you can perform the adds on a
private destination buffer.

Thanks



  reply	other threads:[~2010-08-19  8:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19  8:25 [PATCH] slip: Use net_device_stats from struct net_device Tobias Klauser
2010-08-19  8:49 ` Eric Dumazet [this message]
2010-08-19  9:12   ` Tobias Klauser
2010-08-26  8:28 ` [PATCH v2] " Tobias Klauser
2010-08-26  8:39   ` Eric Dumazet
2010-08-26  9:18     ` Tobias Klauser
2010-08-27  8:12   ` [PATCH v3] " Tobias Klauser
2010-08-27  8:28     ` Eric Dumazet
2010-08-28  2:26       ` David Miller

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=1282207791.2549.16.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tklauser@distanz.ch \
    /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