lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3367B80B08154D42A3B2BC708B5D41F63F18593D4F@EXMAIL.ad.emulex.com>
Date:	Mon, 13 Jun 2011 00:09:38 -0700
From:	<Sathya.Perla@...lex.Com>
To:	<eric.dumazet@...il.com>, <davem@...emloft.net>
CC:	<netdev@...r.kernel.org>
Subject: RE: [PATCH] be2net: fix netdev_stats_update()

Thanks Eric. Will do.

Dave, I would prefer to send a separate patch fixing the netdev stats issue after you apply this multiple TXQ patch. Are you OK with that?

> -----Original Message-----
> From: Eric Dumazet [mailto:eric.dumazet@...il.com]
> Sent: Monday, June 13, 2011 12:19 PM
> To: Perla, Sathya; David Miller
> Cc: netdev@...r.kernel.org
> Subject: [PATCH] be2net: fix netdev_stats_update()
> 
> Le lundi 13 juin 2011 à 11:31 +0530, Sathya Perla a écrit :
> > This patch provides support for multiple TX queues.
> >
> > Signed-off-by: Sathya Perla <sathya.perla@...lex.com>
> > ---
> >  drivers/net/benet/be.h         |   13 ++-
> >  drivers/net/benet/be_ethtool.c |   50 +++++++---
> >  drivers/net/benet/be_main.c    |  227 ++++++++++++++++++++++--------
> ----------
> >  3 files changed, 171 insertions(+), 119 deletions(-)
> >
<snip>
> >  	memset(dev_stats, 0, sizeof(*dev_stats));
> > @@ -450,8 +451,10 @@ void netdev_stats_update(struct be_adapter
> *adapter)
> >  		}
> >  	}
> >
> > -	dev_stats->tx_packets = tx_stats(adapter)->be_tx_pkts;
> > -	dev_stats->tx_bytes = tx_stats(adapter)->be_tx_bytes;
> > +	for_all_tx_queues(adapter, txo, i) {
> > +		dev_stats->tx_packets += tx_stats(txo)->be_tx_pkts;
> > +		dev_stats->tx_bytes += tx_stats(txo)->be_tx_bytes;
> > +	}
> >
> >  	/* bad pkts received */
> >  	dev_stats->rx_errors = drvs->rx_crc_errors +
> > @@ -554,9 +557,9 @@ static u32 be_calc_rate(u64 bytes, unsigned long
> ticks)
> >  	return rate;
> >  }
> >
> 
> Hi Sathya
> 
> Browsing into this patch made me realize be2net netdev_stats_update()
> is
> wrong.
> 
> It should not reset even temporarly netdev->stats.
> 
> You should have something like the following I cooked for linux-2.6, so
> that you get the idea. Please respin your patch after applying
> following
> fix.
> 
> [PATCH] be2net: fix netdev_stats_update()
> 
> Since this driver uses the default dev_get_stats() [ as it doesnt
> provide ndo_get_stats() nor ndo_get_stats64() method ], resetting
> netdev->stats can lead some SNMP readers catching intermediate values,
> breaking the rule that counters only can increase in time.
> 
> We instead should use temporary accumulators and only set netdev->stats
> values with final results.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@...il.com>
> ---
>  drivers/net/benet/be_main.c |   17 +++++++++++------
>  1 files changed, 11 insertions(+), 6 deletions(-)
> diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
> index a485f7f..962509d 100644
> --- a/drivers/net/benet/be_main.c
> +++ b/drivers/net/benet/be_main.c
> @@ -427,28 +427,33 @@ void netdev_stats_update(struct be_adapter
> *adapter)
>  	struct be_drv_stats *drvs = &adapter->drv_stats;
>  	struct net_device_stats *dev_stats = &adapter->netdev->stats;
>  	struct be_rx_obj *rxo;
> +	unsigned long rx_packets = 0, rx_bytes = 0, multicast = 0;
> +	unsigned long rx_dropped = 0;
>  	int i;
> 
> -	memset(dev_stats, 0, sizeof(*dev_stats));
>  	for_all_rx_queues(adapter, rxo, i) {
> -		dev_stats->rx_packets += rx_stats(rxo)->rx_pkts;
> -		dev_stats->rx_bytes += rx_stats(rxo)->rx_bytes;
> -		dev_stats->multicast += rx_stats(rxo)->rx_mcast_pkts;
> +		rx_packets += rx_stats(rxo)->rx_pkts;
> +		rx_bytes += rx_stats(rxo)->rx_bytes;
> +		multicast += rx_stats(rxo)->rx_mcast_pkts;
>  		/*  no space in linux buffers: best possible approximation
> */
>  		if (adapter->generation == BE_GEN3) {
>  			if (!(lancer_chip(adapter))) {
>  				struct be_erx_stats_v1 *erx_stats =
>  					be_erx_stats_from_cmd(adapter);
> -				dev_stats->rx_dropped +=
> +				rx_dropped +=
>  				erx_stats->rx_drops_no_fragments[rxo->q.id];
>  			}
>  		} else {
>  			struct be_erx_stats_v0 *erx_stats =
>  					be_erx_stats_from_cmd(adapter);
> -			dev_stats->rx_dropped +=
> +			rx_dropped +=
>  				erx_stats->rx_drops_no_fragments[rxo->q.id];
>  		}
>  	}
> +	dev_stats->rx_packets = rx_packets;
> +	dev_stats->rx_bytes = rx_bytes;
> +	dev_stats->multicast = multicast;
> +	dev_stats->rx_dropped = rx_dropped;
> 
>  	dev_stats->tx_packets = tx_stats(adapter)->be_tx_pkts;
>  	dev_stats->tx_bytes = tx_stats(adapter)->be_tx_bytes;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ