tcp: fix FIONREAD/SIOCINQ
authorEric Dumazet <edumazet@google.com>
Thu, 18 Oct 2012 09:14:12 +0000 (09:14 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 16 Nov 2012 16:47:15 +0000 (16:47 +0000)
commite8c9f482ed9dc59f3747a065e497854ddd174e60
treee192f7be5f840d0a6aedbc2473969812d809bc00
parent9e4ac2075cbf126be9e37762c8c1c6aec714dcc5
tcp: fix FIONREAD/SIOCINQ

[ Upstream commit a3374c42aa5f7237e87ff3b0622018636b0c847e ]

tcp_ioctl() tries to take into account if tcp socket received a FIN
to report correct number bytes in receive queue.

But its flaky because if the application ate the last skb,
we return 1 instead of 0.

Correct way to detect that FIN was received is to test SOCK_DONE.

Reported-by: Elliot Hughes <enh@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv4/tcp.c