tun: Add ioctl() TUNGETDEVNETNS cmd to allow obtaining real net ns of tun device
authorKirill Tkhai <ktkhai@virtuozzo.com>
Wed, 20 Mar 2019 09:16:42 +0000 (12:16 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Mar 2019 20:19:15 +0000 (13:19 -0700)
commit0c3e0e3bb623c3735b8c9ab8aa8332f944f83a9f
treea0bf65cefd6045f9942a5f010121d4a73964b1b8
parent28b18b39c5a7df75ff657bd9e09f3b8091651e61
tun: Add ioctl() TUNGETDEVNETNS cmd to allow obtaining real net ns of tun device

In commit f2780d6d7475 "tun: Add ioctl() SIOCGSKNS cmd to allow
obtaining net ns of tun device" it was missed that tun may change
its net ns, while net ns of socket remains the same as it was
created initially. SIOCGSKNS returns net ns of socket, so it is
not suitable for obtaining net ns of device.

We may have two tun devices with the same names in two net ns,
and in this case it's not possible to determ, which of them
fd refers to (TUNGETIFF will return the same name).

This patch adds new ioctl() cmd for obtaining net ns of a device.

Reported-by: Harald Albrecht <harald.albrecht@gmx.net>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c
include/uapi/linux/if_tun.h