netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: David Wei <dw@davidwei.uk>
Cc: Jiri Pirko <jiri@resnulli.us>,
	Sabrina Dubroca <sd@queasysnail.net>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next v6 2/4] netdevsim: forward skbs from one connected port to another
Date: Thu, 25 Jan 2024 18:26:32 -0800	[thread overview]
Message-ID: <20240125182632.47652d20@kernel.org> (raw)
In-Reply-To: <20240126012357.535494-3-dw@davidwei.uk>

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;

  reply	other threads:[~2024-01-26  2:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  1:23 [PATCH net-next v6 0/4] netdevsim: link and forward skbs between ports David Wei
2024-01-26  1:23 ` [PATCH net-next v6 1/4] netdevsim: allow two netdevsim ports to be connected David Wei
2024-01-26  2:24   ` Jakub Kicinski
2024-01-26 18:54     ` David Wei
2024-01-26 19:17       ` Jakub Kicinski
2024-01-26  1:23 ` [PATCH net-next v6 2/4] netdevsim: forward skbs from one connected port to another David Wei
2024-01-26  2:26   ` Jakub Kicinski [this message]
2024-01-26 18:55     ` David Wei
2024-01-26  1:23 ` [PATCH net-next v6 3/4] netdevsim: add selftest for forwarding skb between connected ports David Wei
2024-01-26  1:23 ` [PATCH net-next v6 4/4] netdevsim: add Makefile for selftests David Wei

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=20240125182632.47652d20@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    /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;
as well as URLs for NNTP newsgroup(s).