From: Pavel Emelyanov <xemul@parallels.com>
To: David Miller <davem@davemloft.net>,
Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH 4/4] tun: Get skfilter layout
Date: Wed, 21 Aug 2013 14:32:39 +0400 [thread overview]
Message-ID: <52149747.8010208@parallels.com> (raw)
In-Reply-To: <521496EF.8090909@parallels.com>
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>
---
drivers/net/tun.c | 10 ++++++++++
include/uapi/linux/if_tun.h | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6acbdbc..60a1e93 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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;
diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index cc127b2..e9502dd 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -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
--
1.7.6.5
next prev parent reply other threads:[~2013-08-21 10:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 10:31 [PATCH net-next 0/4] tun: Some bits required for tun's checkpoint-restore (v2) Pavel Emelyanov
2013-08-21 10:31 ` [PATCH 1/4] tun: Add ability to create tun device with given index Pavel Emelyanov
2013-08-21 10:32 ` [PATCH 2/4] tun: Report whether the queue is attached or not Pavel Emelyanov
2013-08-21 10:32 ` [PATCH 3/4] tun: Allow to skip filter on attach Pavel Emelyanov
2013-08-21 10:32 ` Pavel Emelyanov [this message]
2013-08-21 19:22 ` [PATCH net-next 0/4] tun: Some bits required for tun's checkpoint-restore (v2) David Miller
-- strict thread matches above, loose matches on Subject: below --
2013-08-19 15:09 [PATCH net-next 0/4] tun: Some bits required for tun's checkpoint-restore Pavel Emelyanov
2013-08-19 15:10 ` [PATCH 4/4] tun: Get skfilter layout Pavel Emelyanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52149747.8010208@parallels.com \
--to=xemul@parallels.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).