Thread (20 messages) 20 messages, 5 authors, 2015-02-28

new link failing on duplicate names in different namespaces

flat view

From: Eugene Yakubovich <hidden>
Date: 2015-02-25 00:48:11

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help