From: Jiri Pirko <jiri@resnulli.us>
To: David Wei <dw@davidwei.uk>
Cc: Jakub Kicinski <kuba@kernel.org>,
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 2/3] netdevsim: forward skbs from one connected
Date: Fri, 8 Dec 2023 12:01:36 +0100 [thread overview]
Message-ID: <ZXL3kL6EPLNa+c7Z@nanopsycho> (raw)
In-Reply-To: <20231207172117.3671183-3-dw@davidwei.uk>
Thu, Dec 07, 2023 at 06:21:16PM CET, dw@davidwei.uk wrote:
>Forward skbs sent from one netdevsim port to its connected netdevsim
>port using dev_forward_skb, in a spirit similar to veth.
>
>Signed-off-by: David Wei <dw@davidwei.uk>
>---
> drivers/net/netdevsim/netdev.c | 20 +++++++++++++++-----
> 1 file changed, 15 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
>index 1abdcd470f21..698819072c4f 100644
>--- a/drivers/net/netdevsim/netdev.c
>+++ b/drivers/net/netdevsim/netdev.c
>@@ -29,19 +29,30 @@
> static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
> {
> struct netdevsim *ns = netdev_priv(dev);
>+ struct netdevsim *peer_ns;
>+ int ret = NETDEV_TX_OK;
>
> if (!nsim_ipsec_tx(ns, skb))
>- goto out;
>+ goto err;
>
> u64_stats_update_begin(&ns->syncp);
> ns->tx_packets++;
> ns->tx_bytes += skb->len;
> u64_stats_update_end(&ns->syncp);
>
>-out:
>- dev_kfree_skb(skb);
>+ peer_ns = ns->peer;
What is stopping the peer to be removed and freed right now?
>+ if (!peer_ns)
>+ goto err;
>+
>+ skb_tx_timestamp(skb);
>+ if (unlikely(dev_forward_skb(peer_ns->netdev, skb) == NET_RX_DROP))
>+ ret = NET_XMIT_DROP;
>
>- return NETDEV_TX_OK;
>+ return ret;
>+
>+err:
>+ dev_kfree_skb(skb);
>+ return ret;
> }
>
> static void nsim_set_rx_mode(struct net_device *dev)
>@@ -302,7 +313,6 @@ static void nsim_setup(struct net_device *dev)
> eth_hw_addr_random(dev);
>
> dev->tx_queue_len = 0;
>- dev->flags |= IFF_NOARP;
> dev->flags &= ~IFF_MULTICAST;
> dev->priv_flags |= IFF_LIVE_ADDR_CHANGE |
> IFF_NO_QUEUE;
>--
>2.39.3
>
>
next prev parent reply other threads:[~2023-12-08 11:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 17:21 [PATCH net-next 0/3] netdevsim: link and forward skbs between David Wei
2023-12-07 17:21 ` [PATCH net-next 1/3] netdevsim: allow two netdevsim ports to be David Wei
2023-12-08 10:59 ` Jiri Pirko
2023-12-08 21:57 ` David Wei
2023-12-09 10:46 ` Jiri Pirko
2023-12-08 17:58 ` Jakub Kicinski
2023-12-08 22:04 ` David Wei
2023-12-07 17:21 ` [PATCH net-next 2/3] netdevsim: forward skbs from one connected David Wei
2023-12-08 11:01 ` Jiri Pirko [this message]
2023-12-08 21:58 ` David Wei
2023-12-07 17:21 ` [PATCH net-next 3/3] selftest: netdevsim: add selftest for David Wei
2023-12-08 10:13 ` [PATCH net-next 0/3] netdevsim: link and forward skbs between Jiri Pirko
2023-12-08 21:45 ` 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=ZXL3kL6EPLNa+c7Z@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.