netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tuntap: raise EPOLLOUT on device up
@ 2018-05-18 13:00 Jason Wang
  2018-05-18 13:13 ` Michael S. Tsirkin
  2018-05-21 15:47 ` David Miller
  0 siblings, 2 replies; 15+ messages in thread
From: Jason Wang @ 2018-05-18 13:00 UTC (permalink / raw)
  To: netdev, linux-kernel; +Cc: mst, Jason Wang, Hannes Frederic Sowa, Eric Dumazet

We return -EIO on device down but can not raise EPOLLOUT after it was
up. This may confuse user like vhost which expects tuntap to raise
EPOLLOUT to re-enable its TX routine after tuntap is down. This could
be easily reproduced by transmitting packets from VM while down and up
the tap device. Fixing this by set SOCKWQ_ASYNC_NOSPACE on -EIO.

Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Eric Dumazet <edumazet@google.com>
Fixes: 1bd4978a88ac2 ("tun: honor IFF_UP in tun_get_user()")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/tun.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d45ac37..1b29761 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1734,8 +1734,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 	int skb_xdp = 1;
 	bool frags = tun_napi_frags_enabled(tun);
 
-	if (!(tun->dev->flags & IFF_UP))
+	if (!(tun->dev->flags & IFF_UP)) {
+		set_bit(SOCKWQ_ASYNC_NOSPACE, &tfile->socket.flags);
 		return -EIO;
+	}
 
 	if (!(tun->flags & IFF_NO_PI)) {
 		if (len < sizeof(pi))
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-05-22  4:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18 13:00 [PATCH net] tuntap: raise EPOLLOUT on device up Jason Wang
2018-05-18 13:13 ` Michael S. Tsirkin
2018-05-18 13:26   ` Jason Wang
2018-05-18 14:00     ` Jason Wang
2018-05-18 14:06       ` Michael S. Tsirkin
2018-05-18 14:11         ` Jason Wang
2018-05-18 14:46           ` Michael S. Tsirkin
2018-05-19  1:09             ` Jason Wang
2018-05-21 22:06               ` Michael S. Tsirkin
2018-05-21 15:47 ` David Miller
2018-05-21 22:08   ` Michael S. Tsirkin
2018-05-22  3:22     ` Jason Wang
2018-05-22  3:45       ` Michael S. Tsirkin
2018-05-22  3:46       ` Michael S. Tsirkin
2018-05-22  4:00         ` Jason Wang

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).