]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitee65008fe43c41937a17053888fcca0125a7048f
treea0bf65cefd6045f9942a5f010121d4a73964b1b8
parent750d6af80ba491a28886ae17e695ef5228334d9e
tun: Add ioctl() TUNGETDEVNETNS cmd to allow obtaining real net ns of tun device

In commit 92f842a5e70f "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