diff mbox series

[net-next] net: tap: fix POLLOUT condition in tap_poll()

Message ID 1513261336-5209-1-git-send-email-cugyly@163.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [net-next] net: tap: fix POLLOUT condition in tap_poll() | expand

Commit Message

yuan linyu Dec. 14, 2017, 2:22 p.m. UTC
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

from logical view, if sock_writeable(&q->sk) return false,
original second condition will return false too,
change it and make second condition can return true.

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 drivers/net/tap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

David Miller Dec. 17, 2017, 4:03 a.m. UTC | #1
From: yuan linyu <cugyly@163.com>
Date: Thu, 14 Dec 2017 22:22:16 +0800

> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> 
> from logical view, if sock_writeable(&q->sk) return false,
> original second condition will return false too,
> change it and make second condition can return true.
> 
> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
 ...
> @@ -587,8 +587,7 @@ static unsigned int tap_poll(struct file *file, poll_table *wait)
>  		mask |= POLLIN | POLLRDNORM;
>  
>  	if (sock_writeable(&q->sk) ||
> -	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags) &&
> -	     sock_writeable(&q->sk)))
> +	    !test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags))
>  		mask |= POLLOUT | POLLWRNORM;
>  
>  out:
> -- 
> 2.7.4

Hmmm, this same exact test also exists in tun_chr_poll().

The second condition probably never trigger, because of the reasons
you have listed.  The only side effect is that it will set the
ASYNC_NOSPACE bit in the socket flags.

Logically, it seems we can remove the second condition altogether.

But I wonder what might break if we stop trying to set that socket
flags bit in this situation.

Overall, I'm not sure this change is safe at all.
diff mbox series

Patch

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 0a886fda..72212bf 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -587,8 +587,7 @@  static unsigned int tap_poll(struct file *file, poll_table *wait)
 		mask |= POLLIN | POLLRDNORM;
 
 	if (sock_writeable(&q->sk) ||
-	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags) &&
-	     sock_writeable(&q->sk)))
+	    !test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags))
 		mask |= POLLOUT | POLLWRNORM;
 
 out: