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: <20230602102710.vnfh774wkpt7rclg@skbuf>
Date: Fri, 2 Jun 2023 13:27:10 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: wei.fang@....com
Cc: claudiu.manoil@....com, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.or, pabeni@...hat.com, ast@...nel.org,
	daniel@...earbox.net, hawk@...nel.org, john.fastabend@...il.com,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net 1/2] net: enetc: correct the statistics of rx bytes

Hi Wei,

On Fri, Jun 02, 2023 at 05:46:58PM +0800, wei.fang@....com wrote:
> From: Wei Fang <wei.fang@....com>
> 
> The rx_bytes of struct net_device_stats should count the length of
> ethernet frames excluding the FCS. However, there are two problems
> with the rx_bytes statistics of the current enetc driver. one is
> that the length of VLAN header is not counted if the VLAN extraction
> feature is enabled. The other is that the length of L2 header is not
> counted, because eth_type_trans() is invoked before updating rx_bytes
> which will subtract the length of L2 header from skb->len.

Thanks for noticing the issue and for sending a patch.

> BTW, the rx_bytes statistics of XDP path also have similar problem,
> I will fix it in another patch.
> 
> Fixes: a800abd3ecb9 ("net: enetc: move skb creation into enetc_build_skb")
> Signed-off-by: Wei Fang <wei.fang@....com>
> ---
>  drivers/net/ethernet/freescale/enetc/enetc.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 3c4fa26f0f9b..d6c0f3f46c2a 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1229,7 +1229,13 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
>  		if (!skb)
>  			break;
>  
> -		rx_byte_cnt += skb->len;
> +		/* When set, the outer VLAN header is extracted and reported
> +		 * in the receive buffer descriptor. So rx_byte_cnt should
> +		 * add the length of the extracted VLAN header.
> +		 */
> +		if (bd_status & ENETC_RXBD_FLAG_VLAN)
> +			rx_byte_cnt += VLAN_HLEN;
> +		rx_byte_cnt += skb->len + ETH_HLEN;

Hmm, to avoid the conditional, have you considered adding an "int *rx_byte_cnt"
argument to enetc_build_skb()? It can be updated with "(*rx_byte_cnt) += size"
from all places where we already have "(*cleaned_cnt)++".

>  		rx_frm_cnt++;
>  
>  		napi_gro_receive(napi, skb);
> -- 
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ