History

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

Pavel Emelyanov committed 13 years ago

Commit fb7589a1 parent 5f1cd202 files · +21 −1Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/if_tun.h+1−0
@@ -56,6 +56,7 @@ · 55 unmodified lines
5656 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
5757 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
5858 #define TUNSETQUEUE _IOW('T', 217, int)
59+#define TUNSETIFINDEX _IOW('T', 218, unsigned int)
5960
6061 /* TUNSETIFF ifr flags */
6162 #define IFF_TUN 0x0001

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t