]> git.baikalelectronics.ru Git - kernel.git/commit
tun: Add ability to create tun device with given index
authorPavel Emelyanov <xemul@parallels.com>
Wed, 21 Aug 2013 10:31:38 +0000 (14:31 +0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Aug 2013 19:21:45 +0000 (12:21 -0700)
commite4d70bc78d0e2d85dc0a2821a11fc75681c09e10
treef99c3c7c9af2681f57b8b7beb4b859bf9d2bf4f5
parent2e100a1a93a19e397296ab28334859f5e92e3671
tun: Add ability to create tun device with given index

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 (a78e3ef0 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
(90fbe240 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 N, should open
the tun device, call ioctl(fd, TUNSETIFINDEX, &N), then call TUNSETIFF.
If the index N is busy, then the register_netdev will find this out
and the ioctl would be failed with -EBUSY.

If setifindex is not called, then it will be generated as before.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c
include/uapi/linux/if_tun.h