netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* new link failing on duplicate names in different namespaces
@ 2015-02-25  0:48 Eugene Yakubovich
  2015-02-25 16:26 ` Nicolas Dichtel
  0 siblings, 1 reply; 20+ messages in thread
From: Eugene Yakubovich @ 2015-02-25  0:48 UTC (permalink / raw)
  To: netdev

Hello,

rtnetlink's RTM_NEWLINK allows for specifying the network namespace in
which the link is to be created via IFLA_NET_NS_PID or IFLA_NET_NS_FD.
This not only saves a user a call to move the link into the target
namespace, it can avoid a potential ifname conflict. For example, if
creating eth0 in another namespace and the current one already has
eth0.

Unfortunately, this is not the current behavior. If the user specifies
IFLA_IFNAME, leaves ifinfomsg.ifi_index unspecified and sets
NLM_F_EXCL flag, as in the case of creating a new link, the call will
fail with EEXIST in cases where there's a name conflict.

rtnl_newlink() will:

if (ifname[0])
    dev = __dev_get_by_name(net, ifname);

and later:

if (dev) {
    int status = 0;

    if (nlh->nlmsg_flags & NLM_F_EXCL)
        return -EEXIST;
...
}

I am not sure if this has been discussed before or if it's viewed as a
real problem. Fixing this however, would make it easier to work with
interfaces in different network namespaces. I don't have a good
solution in mind though and so I can't propose a patch at this time.

Thanks,
Eugene

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-02-28 20:15 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25  0:48 new link failing on duplicate names in different namespaces Eugene Yakubovich
2015-02-25 16:26 ` Nicolas Dichtel
2015-02-25 17:44   ` Eric W. Biederman
2015-02-26  5:29     ` Cong Wang
2015-02-26  5:56       ` Cong Wang
2015-02-26  9:14         ` Nicolas Dichtel
2015-02-26 13:55           ` Eric W. Biederman
2015-02-26 14:40             ` Nicolas Dichtel
2015-02-27  0:22           ` Cong Wang
2015-02-25 19:03   ` What are the intended semantics of IFLA_LINK_NETNSID? Eric W. Biederman
2015-02-26  5:07     ` Cong Wang
2015-02-26  8:55     ` Nicolas Dichtel
2015-02-26 13:48       ` Eric W. Biederman
2015-02-26 14:52         ` Nicolas Dichtel
2015-02-26 22:19           ` [PATCH net 1/2] net: Verify permission to dest_net in newlink Eric W. Biederman
2015-02-26 22:20             ` [PATCH net 2/2] net: Verify permission to link_net " Eric W. Biederman
2015-02-27  9:03               ` Nicolas Dichtel
2015-02-28 20:15               ` David Miller
2015-02-27  9:03             ` [PATCH net 1/2] net: Verify permission to dest_net " Nicolas Dichtel
2015-02-28 20:15             ` David Miller

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).