diff mbox

[SRU,Vivid,1/1] tun: return proper error code from tun_do_read

Message ID 5ab969f8fddda9e48df8621ef5e3d3df8740446a.1430252883.git.joseph.salisbury@canonical.com
State New
Headers show

Commit Message

Joseph Salisbury April 28, 2015, 8:38 p.m. UTC
From: Alex Gartrell <agartrell@fb.com>

BugLink: http://bugs.launchpad.net/bugs/1448942

Instead of -1 with EAGAIN, read on a O_NONBLOCK tun fd will return 0.  This
fixes this by properly returning the error code from __skb_recv_datagram.

Signed-off-by: Alex Gartrell <agartrell@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 957f094f221f81e457133b1f4c4d95ffa49ff731)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
---
 drivers/net/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Bader April 29, 2015, 11:47 a.m. UTC | #1
Looks reasonable and doing what it claims.
Tim Gardner April 29, 2015, 11:52 a.m. UTC | #2

Brad Figg May 4, 2015, 3:40 p.m. UTC | #3
On Tue, Apr 28, 2015 at 04:38:40PM -0400, Joseph Salisbury wrote:
> From: Alex Gartrell <agartrell@fb.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1448942
> 
> Instead of -1 with EAGAIN, read on a O_NONBLOCK tun fd will return 0.  This
> fixes this by properly returning the error code from __skb_recv_datagram.
> 
> Signed-off-by: Alex Gartrell <agartrell@fb.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit 957f094f221f81e457133b1f4c4d95ffa49ff731)
> Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
> ---
>  drivers/net/tun.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 10f9e40..9a409a8f 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1368,7 +1368,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
>  	skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
>  				  &peeked, &off, &err);
>  	if (!skb)
> -		return 0;
> +		return err;
>  
>  	ret = tun_put_user(tun, tfile, skb, to);
>  	if (unlikely(ret < 0))
> -- 
> 2.1.0
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Applied to Vivid master-next.
diff mbox

Patch

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 10f9e40..9a409a8f 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1368,7 +1368,7 @@  static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
 	skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
 				  &peeked, &off, &err);
 	if (!skb)
-		return 0;
+		return err;
 
 	ret = tun_put_user(tun, tfile, skb, to);
 	if (unlikely(ret < 0))