netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Haller <thaller@redhat.com>
To: Jiri Benc <jbenc@redhat.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>,
	David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net] net: try harder to not reuse ifindex when moving interfaces
Date: Thu, 22 Oct 2015 17:20:40 +0200	[thread overview]
Message-ID: <1445527240.7084.46.camel@redhat.com> (raw)
In-Reply-To: <20151022170100.1e45a8b8@griffin>

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

On Thu, 2015-10-22 at 17:00 +0200, Jiri Benc wrote:
> On Thu, 22 Oct 2015 16:52:13 +0200, Nicolas Dichtel wrote:
> > With the proposed scenario:
> > 1. create netns 'new_netns'
> > 2. in root netns, move the interface with ifindex 2 to new_netns
> > 3. in new_netns, delete the interface with ifindex 2
> > 4. in new_netns, create an interface - it will get ifindex 2
> > 
> > Operation 2 and 4 are done by dev_change_net_namespace() under
> > rtnl_lock().
> > RTM_DELLINK(root netns) and RTM_NEWLINK(new_netns) are sent by this
> > function.
> > It means that operation 3 has been done before and that
> > RTM_DELLINK(new_netns)
> > has been sent before.
> 
> Imagine the application trying to configure the interface with
> ifindex 2
> after your step 2. It constructs a netlink message and sends it to
> the
> kernel; but while doing so, steps 3 and 4 happen. Now the application
> ends up configuring a different interface than it intended to. After
> that, it polls the netlink socket and receives the notifications
> about
> interface disappearing and a new one appearing.
> 
> I don't see any way the user space application can prevent this.
> There
> will always be a race between receiving netlink notifications and
> sending config requests.
> 
> I guess Thomas Haller can elaborate more as he ran into this.

Jiri,

It's really just what you said.

Whatever action the application wants to perform when using the
ifindex, there is a time-window between learning about the ifindex
and using it.

There is nothing userspace can do except trying to hurry and hoping for
the best.


Thomas

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-10-22 15:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16 11:07 [PATCH net] net: try harder to not reuse ifindex when moving interfaces Jiri Benc
2015-10-18 15:11 ` Alexei Starovoitov
2015-10-19  9:06   ` Jiri Benc
2015-10-19 15:36     ` Alexei Starovoitov
2015-10-21 14:43 ` David Miller
2015-10-21 14:46   ` Jiri Benc
2015-10-21 15:32     ` David Miller
2015-10-21 15:25       ` Jiri Benc
2015-10-21 15:56         ` David Miller
2015-10-21 17:12           ` Hannes Frederic Sowa
2015-10-22 14:52             ` Nicolas Dichtel
2015-10-22 15:00               ` Jiri Benc
2015-10-22 15:10                 ` Hannes Frederic Sowa
2015-10-22 15:20                 ` Thomas Haller [this message]
2015-10-22 15:23                 ` Nicolas Dichtel
2015-10-22 16:45                 ` Thomas Graf
2015-10-22 17:21                   ` Hannes Frederic Sowa
2015-10-22 18:56                     ` Thomas Graf
2015-10-23 10:40                       ` Thomas Haller
2015-10-22 15:21               ` Thomas Haller

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=1445527240.7084.46.camel@redhat.com \
    --to=thaller@redhat.com \
    --cc=davem@davemloft.net \
    --cc=hannes@stressinduktion.org \
    --cc=jbenc@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.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 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).