Subject: Re: [PATCH net-next v6 2/4] netdevsim: forward skbs from one connected port to another

From: Jakub Kicinski <[email-masked]>
Date: Thu, 25 Jan 2024 18:26:32 -0800

On Thu, 25 Jan 2024 17:23:55 -0800 David Wei wrote:
>  	struct netdevsim *ns = netdev_priv(dev);
> +	struct netdevsim *peer_ns;
> +	unsigned int len = skb->len;
> +	int ret = NETDEV_TX_OK;

nit: order variables longest to shortest

>  	if (!nsim_ipsec_tx(ns, skb))
>  		goto out;
>  
> +	rcu_read_lock();
> +	peer_ns = rcu_dereference(ns->peer);
> +	if (!peer_ns)
> +		goto out_stats;
> +
> +	skb_tx_timestamp(skb);
> +	if (unlikely(dev_forward_skb(peer_ns->netdev, skb) == NET_RX_DROP))
> +		ret = NET_XMIT_DROP;
> +
> +out_stats:
> +	rcu_read_unlock();
>  	u64_stats_update_begin(&ns->syncp);
>  	ns->tx_packets++;
> -	ns->tx_bytes += skb->len;
> +	ns->tx_bytes += len;
> +	if (ret == NET_XMIT_DROP)
> +		ns->tx_dropped++;

drops should not be counted as Tx

>  	u64_stats_update_end(&ns->syncp);
> +	return ret;