netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Vagin <avagin@gmail.com>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org,
	Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Subject: Re: [PATCH net-next] net: Allow to specify ifindex when device is moved to another namespace
Date: Fri, 2 Apr 2021 09:57:52 -0700	[thread overview]
Message-ID: <YGdNEADhQnT+Jmi7@gmail.com> (raw)
In-Reply-To: <20210402082014.y6efckcpx3y7heo6@wittgenstein>

On Fri, Apr 02, 2021 at 10:20:14AM +0200, Christian Brauner wrote:
> > @@ -11043,6 +11046,11 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
> >  			goto out;
> >  	}
> >  
> > +	/* Check that new_ifindex isn't used yet. */
> > +	err = -EBUSY;
> > +	if (new_ifindex && __dev_get_by_index(net, new_ifindex))
> > +		goto out;
> 
> Should this maybe verify that the new_inindex isn't negative and reject
> it right away? (Maybe also right where we first retrieve it?) Otherwise
> __dev_get_by_index() might pointlessly walk the whole netdev list for
> thet network namespace.
> 

I think __dev_get_by_index works fine for links with negative
ifindices, but there are other places where we expect that ifindex is
positive, so I think you are right, we need to check that it isn't
negative here and we need to add the same check in register_netdevice
too.

Thanks,
Andrei

  reply	other threads:[~2021-04-02 17:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02  7:36 [PATCH net-next] net: Allow to specify ifindex when device is moved to another namespace Andrei Vagin
2021-04-02  8:17 ` Andrei Vagin
2021-04-02  8:20 ` Christian Brauner
2021-04-02 16:57   ` Andrei Vagin [this message]
2021-04-02  8:29 ` [PATCH net-next v2] " Andrei Vagin
2021-04-05  7:12 ` [PATCH] " Andrei Vagin
2021-04-05 12:15   ` Christian Brauner
2021-04-05 22:10   ` patchwork-bot+netdevbpf
2021-04-05 22:15   ` Jakub Kicinski

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=YGdNEADhQnT+Jmi7@gmail.com \
    --to=avagin@gmail.com \
    --cc=alexander.mikhalitsyn@virtuozzo.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).