[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191218081050.10170-15-prashantbhole.linux@gmail.com>
Date: Wed, 18 Dec 2019 17:10:50 +0900
From: Prashant Bhole <prashantbhole.linux@...il.com>
To: "David S . Miller" <davem@...emloft.net>,
"Michael S . Tsirkin" <mst@...hat.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>
Cc: Prashant Bhole <prashantbhole.linux@...il.com>,
Jason Wang <jasowang@...hat.com>,
David Ahern <dsahern@...il.com>,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
John Fastabend <john.fastabend@...il.com>,
Toshiaki Makita <toshiaki.makita1@...il.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andriin@...com>, netdev@...r.kernel.org
Subject: [RFC net-next 14/14] tun: run xdp prog when tun is read from file interface
It handles the case when qemu performs read on tun using file
operations.
Signed-off-by: Prashant Bhole <prashantbhole.linux@...il.com>
---
drivers/net/tun.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8e2fe0ad7955..0a9ac380c1b4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2335,8 +2335,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
struct iov_iter *to,
int noblock, void *ptr)
{
+ struct xdp_frame *frame;
ssize_t ret;
int err;
+ u32 act;
tun_debug(KERN_INFO, tun, "tun_do_read\n");
@@ -2350,6 +2352,15 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
ptr = tun_ring_recv(tfile, noblock, &err);
if (!ptr)
return err;
+
+ if (tun_is_xdp_frame(ptr)) {
+ frame = tun_ptr_to_xdp(ptr);
+ act = tun_do_xdp_tx(tun, tfile, frame);
+ } else {
+ act = tun_do_xdp_tx_generic(tun, ptr);
+ }
+ if (act != XDP_PASS)
+ return err;
}
if (tun_is_xdp_frame(ptr)) {
--
2.21.0
Powered by blists - more mailing lists