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 v11 1/3] netdevsim: allow two netdevsim ports to be connected
Date: Fri, 16 Feb 2024 17:46:46 -0800	[thread overview]
Message-ID: <20240216174646.6a0dd168@kernel.org> (raw)
In-Reply-To: <20240215194325.1364466-2-dw@davidwei.uk>

On Thu, 15 Feb 2024 11:43:23 -0800 David Wei wrote:
> +	ns_a = get_net_ns_by_fd(netnsfd_a);
> +	if (IS_ERR(ns_a)) {
> +		pr_err("Could not find netns with fd: %d\n", netnsfd_a);
> +		return -EINVAL;
> +	}
> +
> +	ns_b = get_net_ns_by_fd(netnsfd_b);
> +	if (IS_ERR(ns_b)) {
> +		pr_err("Could not find netns with fd: %d\n", netnsfd_b);
> +		return -EINVAL;
> +	}
> +
> +	err = -EINVAL;
> +	rtnl_lock();
> +	dev_a = __dev_get_by_index(ns_a, ifidx_a);
> +	if (!dev_a) {
> +		pr_err("Could not find device with ifindex %u in netnsfd %d\n", ifidx_a, netnsfd_a);
> +		goto out_put_netns_a;
> +	}
> +
> +	if (!netdev_is_nsim(dev_a)) {
> +		pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_a, netnsfd_a);
> +		goto out_put_netns_a;
> +	}
> +
> +	dev_b = __dev_get_by_index(ns_b, ifidx_b);
> +	if (!dev_b) {
> +		pr_err("Could not find device with ifindex %u in netnsfd %d\n", ifidx_b, netnsfd_b);
> +		goto out_put_netns_b;
> +	}
> +
> +	if (!netdev_is_nsim(dev_b)) {
> +		pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_b, netnsfd_b);
> +		goto out_put_netns_b;
> +	}
> +
> +	if (dev_a == dev_b) {
> +		pr_err("Cannot link a netdevsim to itself\n");
> +		goto out_put_netns_b;

You need to fix the gotos here :( You're leaking the references 
to the namespaces on error paths :(
-- 
pw-bot: cr

  reply	other threads:[~2024-02-17  1:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 19:43 [PATCH net-next v11 0/3] netdevsim: link and forward skbs between ports David Wei
2024-02-15 19:43 ` [PATCH net-next v11 1/3] netdevsim: allow two netdevsim ports to be connected David Wei
2024-02-17  1:46   ` Jakub Kicinski [this message]
2024-02-17  2:53     ` David Wei
2024-02-15 19:43 ` [PATCH net-next v11 2/3] netdevsim: forward skbs from one connected port to another David Wei
2024-02-15 19:43 ` [PATCH net-next v11 3/3] netdevsim: add selftest for forwarding skb between connected ports David Wei
2024-02-16 10:38 ` [PATCH net-next v11 0/3] netdevsim: link and forward skbs between ports Paolo Abeni
2024-02-16 14:44   ` Jakub Kicinski
2024-02-16 19:13   ` David Wei
2024-02-17  1:47     ` Jakub Kicinski
2024-02-17  2:52       ` David Wei
2024-02-17  1:48     ` Jakub Kicinski
2024-02-17  3:27       ` David Wei
2024-02-19 19:20         ` Jakub Kicinski
2024-02-20  3:42           ` 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=20240216174646.6a0dd168@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).