summaryrefslogtreecommitdiff
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2020-11-28 05:25:27 +0300
committerJakub Kicinski <kuba@kernel.org>2020-11-28 05:25:27 +0300
commit5c39f26e67c984db0fa95f9faecf06eb0198dce7 (patch)
tree821aaa43d3f5806134438daa531be6d171292c5f /drivers/net/tun.c
parent6375da9dac8bec05a022f22ab22300cc824ec268 (diff)
parentc84e1efae022071a4fcf9f1899bf71777c49943a (diff)
downloadlinux-5c39f26e67c984db0fa95f9faecf06eb0198dce7.tar.xz
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Trivial conflict in CAN, keep the net-next + the byteswap wrapper. Conflicts: drivers/net/can/usb/gs_usb.c Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7c62d82c57db..2dc1988a8973 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1921,12 +1921,15 @@ static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from)
struct tun_file *tfile = file->private_data;
struct tun_struct *tun = tun_get(tfile);
ssize_t result;
+ int noblock = 0;
if (!tun)
return -EBADFD;
- result = tun_get_user(tun, tfile, NULL, from,
- file->f_flags & O_NONBLOCK, false);
+ if ((file->f_flags & O_NONBLOCK) || (iocb->ki_flags & IOCB_NOWAIT))
+ noblock = 1;
+
+ result = tun_get_user(tun, tfile, NULL, from, noblock, false);
tun_put(tun);
return result;
@@ -2137,10 +2140,15 @@ static ssize_t tun_chr_read_iter(struct kiocb *iocb, struct iov_iter *to)
struct tun_file *tfile = file->private_data;
struct tun_struct *tun = tun_get(tfile);
ssize_t len = iov_iter_count(to), ret;
+ int noblock = 0;
if (!tun)
return -EBADFD;
- ret = tun_do_read(tun, tfile, to, file->f_flags & O_NONBLOCK, NULL);
+
+ if ((file->f_flags & O_NONBLOCK) || (iocb->ki_flags & IOCB_NOWAIT))
+ noblock = 1;
+
+ ret = tun_do_read(tun, tfile, to, noblock, NULL);
ret = min_t(ssize_t, ret, len);
if (ret > 0)
iocb->ki_pos = ret;