Subject: Re: [PATCH net-next] tun: Add ability to create tun device with given index

From: Pavel Emelyanov <[email-masked]>
Date: Fri, 14 Jun 2013 13:34:28 +0400

On 06/13/2013 08:52 PM, Stephen Hemminger wrote:
> On Thu, 13 Jun 2013 14:04:54 +0400
> Pavel Emelyanov <[email-masked]> wrote:
> 
>> Tun devices cannot be created with ifidex user wants, but it's
>> required by checkpoint-restore project.
>>
>> Long time ago such ability was implemented for rtnl_ops-based
>> interface for creating links (9c7dafbf net: Allow to create links
>> with given ifindex), but the only API for creating and managing 
>> tuntap devices is ioctl-based and is evolving with adding new ones
>> (cde8b15f tuntap: add ioctl to attach or detach a file form tuntap
>> device).
>>
>> Following that trend, here's how a new ioctl that sets the ifindex
>> for device, that _will_ be created by TUNSETIFF ioctl looks like.
>> So those who want a tuntap device with the ifindex I, should open
>> the tun device, call ioctl(fd, TUNSETIFINDEX, I), then call TUNSETIFF.
>> If setifindex is not called, then it will be generated as before.
>>
>> Is it OK to extend ioctls with this, or should we rather switch the
>> whole tuntap driver on full-featured rtln-ops?
>>
>> Signed-off-by: Pavel Emelyanov <[email-masked]>
>>
> 
> I see no check for the most fundamental thing, the ifindex must be unique!
> 

The register_netdev() will check for this and report -EBUSY if it is (and
add device to list if not, all atomically).

Thanks,
Pavel