]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tun: Get skfilter layout
authorPavel Emelyanov <xemul@parallels.com>
Wed, 21 Aug 2013 10:32:39 +0000 (14:32 +0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Aug 2013 19:21:45 +0000 (12:21 -0700)
The only thing we may have from tun device is the fprog, whic contains
the number of filter elements and a pointer to (user-space) memory
where the elements are. The program itself may not be available if the
device is persistent and detached.

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

index 6acbdbccebcd8890fe1cca20c82d3c2be7fc3912..60a1e93e9d351a3a9f6e49ac3db1f4da7a25ada8 100644 (file)
@@ -2042,6 +2042,16 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
                tun_detach_filter(tun, tun->numqueues);
                break;
 
+       case TUNGETFILTER:
+               ret = -EINVAL;
+               if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV)
+                       break;
+               ret = -EFAULT;
+               if (copy_to_user(argp, &tun->fprog, sizeof(tun->fprog)))
+                       break;
+               ret = 0;
+               break;
+
        default:
                ret = -EINVAL;
                break;
index cc127b2b4c3dd99873b724be73c6b7fe10e622cb..e9502dd1ee2cc178e712e6ab05c59efecdaf980f 100644 (file)
@@ -57,6 +57,7 @@
 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
 #define TUNSETQUEUE  _IOW('T', 217, int)
 #define TUNSETIFINDEX  _IOW('T', 218, unsigned int)
+#define TUNGETFILTER _IOR('T', 219, struct sock_fprog)
 
 /* TUNSETIFF ifr flags */
 #define IFF_TUN                0x0001