Subject: Re: [PATCH net v2] tun: add missing rx stats accounting in tun_xdp_act

From: Simon Horman <[email-masked]>
Date: Tue, 16 Jan 2024 19:27:57 +0000

On Tue, Jan 16, 2024 at 08:56:58PM +0800, Yunjian Wang wrote:
> There are few places on the receive path where packet receives and packet
> drops were not accounted for. This patch fixes that issue.
> 
> Fixes: 8ae1aff0b331 ("tuntap: split out XDP logic")
> Signed-off-by: Yunjian Wang <[email-masked]>
> ---
> v2: add Fixes tag
> ---
>  drivers/net/tun.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index afa5497f7c35..232e5319ac77 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1626,17 +1626,14 @@ static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog,
>  		       struct xdp_buff *xdp, u32 act)
>  {
>  	int err;
> +	unsigned int datasize = xdp->data_end - xdp->data;

nit: if you post a v3 for some other reason then, as this is Networking
     code, please consider arranging local variables in reverse xmas tree
     order - longest line to shortest.

	unsigned int datasize = xdp->data_end - xdp->data;
	int err;

...