• P
    tun: Add ability to create tun device with given index · fb7589a1
    Pavel Emelyanov 提交于
    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.
    Signed-off-by: NPavel Emelyanov <xemul@parallels.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    fb7589a1
tun.c 53.6 KB