From: Jason Wang <jasowang@redhat.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: mst@redhat.com, willemdebruijn.kernel@gmail.com,
tom@herbertland.com, Jason Wang <jasowang@redhat.com>
Subject: [PATCH net-next V2 2/3] tun: introduce ioctls to set and get steering policies
Date: Tue, 31 Oct 2017 18:32:17 +0800 [thread overview]
Message-ID: <1509445938-4345-3-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1509445938-4345-1-git-send-email-jasowang@redhat.com>
This patch introduces new ioctl for change packet steering policy for
tun. Only automatic flow steering is supported, more policies will
come.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/tun.c | 35 ++++++++++++++++++++++++++++++++++-
include/uapi/linux/if_tun.h | 7 +++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index bff6259..ab109ff 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -122,7 +122,8 @@ do { \
#define TUN_VNET_BE 0x40000000
#define TUN_FEATURES (IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR | \
- IFF_MULTI_QUEUE | IFF_NAPI | IFF_NAPI_FRAGS)
+ IFF_MULTI_QUEUE | IFF_NAPI | IFF_NAPI_FRAGS | \
+ IFF_MULTI_STEERING)
#define GOODCOPY_LEN 128
@@ -2516,6 +2517,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
unsigned int ifindex;
int le;
int ret;
+ unsigned int steering;
if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == SOCK_IOC_TYPE) {
if (copy_from_user(&ifr, argp, ifreq_len))
@@ -2774,6 +2776,37 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
ret = 0;
break;
+ case TUNSETSTEERING:
+ ret = -EFAULT;
+ if (copy_from_user(&steering, argp, sizeof(steering)))
+ break;
+ ret = 0;
+ switch (steering) {
+ case TUN_STEERING_AUTOMQ:
+ tun->steering_ops = &tun_automq_ops;
+ break;
+ default:
+ ret = -EFAULT;
+ }
+ break;
+
+ case TUNGETSTEERING:
+ ret = 0;
+ if (tun->steering_ops == &tun_automq_ops)
+ steering = TUN_STEERING_AUTOMQ;
+ else
+ BUG();
+ if (copy_to_user(argp, &steering, sizeof(steering)))
+ ret = -EFAULT;
+ break;
+
+ case TUNGETSTEERINGFEATURES:
+ ret = 0;
+ steering = TUN_STEERING_AUTOMQ;
+ if (copy_to_user(argp, &steering, sizeof(steering)))
+ ret = -EFAULT;
+ break;
+
default:
ret = -EINVAL;
break;
diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index 365ade5..109760e 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -56,6 +56,9 @@
*/
#define TUNSETVNETBE _IOW('T', 222, int)
#define TUNGETVNETBE _IOR('T', 223, int)
+#define TUNSETSTEERING _IOW('T', 224, unsigned int)
+#define TUNGETSTEERING _IOR('T', 225, unsigned int)
+#define TUNGETSTEERINGFEATURES _IOR('T', 226, unsigned int)
/* TUNSETIFF ifr flags */
#define IFF_TUN 0x0001
@@ -70,6 +73,8 @@
#define IFF_MULTI_QUEUE 0x0100
#define IFF_ATTACH_QUEUE 0x0200
#define IFF_DETACH_QUEUE 0x0400
+#define IFF_MULTI_STEERING 0x2000
+
/* read-only flag */
#define IFF_PERSIST 0x0800
#define IFF_NOFILTER 0x1000
@@ -106,4 +111,6 @@ struct tun_filter {
__u8 addr[0][ETH_ALEN];
};
+#define TUN_STEERING_AUTOMQ 0x01 /* Automatic flow steering */
+
#endif /* _UAPI__IF_TUN_H */
--
2.7.4
next prev parent reply other threads:[~2017-10-31 10:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 10:32 [PATCH net-next V2 0/3] support changing steering policies in tuntap Jason Wang
2017-10-31 10:32 ` [PATCH net-next V2 1/3] tun: abstract flow steering logic Jason Wang
2017-11-02 1:11 ` Willem de Bruijn
2017-11-02 3:43 ` Jason Wang
2017-11-02 3:45 ` Michael S. Tsirkin
2017-11-02 3:51 ` Jason Wang
2017-11-03 8:49 ` Willem de Bruijn
2017-10-31 10:32 ` Jason Wang [this message]
2017-11-02 1:15 ` [PATCH net-next V2 2/3] tun: introduce ioctls to set and get steering policies Willem de Bruijn
2017-10-31 10:32 ` [PATCH net-next V2 3/3] tun: add eBPF based queue selection method Jason Wang
2017-10-31 16:45 ` Michael S. Tsirkin
2017-11-01 13:02 ` Jason Wang
2017-11-01 13:59 ` Michael S. Tsirkin
2017-11-01 19:12 ` Alexei Starovoitov
2017-11-02 3:24 ` Jason Wang
2017-11-02 3:45 ` Jason Wang
2017-11-03 8:56 ` Willem de Bruijn
2017-11-03 23:56 ` Willem de Bruijn
2017-11-08 5:28 ` Jason Wang
2017-11-08 5:43 ` Michael S. Tsirkin
2017-11-08 11:13 ` Jason Wang
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=1509445938-4345-3-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=tom@herbertland.com \
--cc=willemdebruijn.kernel@gmail.com \
/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).