Subject: Re: new link failing on duplicate names in different namespaces

From: Nicolas Dichtel <[email-masked]>
Date: Wed, 25 Feb 2015 17:26:35 +0100

Le 25/02/2015 01:48, Eugene Yakubovich a écrit :
> 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);
Yes, it seems that this should be done in "dest_net" or "link_net".