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>
This commit is contained in:
Eric Dumazet 2012-10-18 09:14:12 +00:00 коммит произвёл David S. Miller
Родитель c6846ee148
Коммит a3374c42aa
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -549,14 +549,12 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
!tp->urg_data || !tp->urg_data ||
before(tp->urg_seq, tp->copied_seq) || before(tp->urg_seq, tp->copied_seq) ||
!before(tp->urg_seq, tp->rcv_nxt)) { !before(tp->urg_seq, tp->rcv_nxt)) {
struct sk_buff *skb;
answ = tp->rcv_nxt - tp->copied_seq; answ = tp->rcv_nxt - tp->copied_seq;
/* Subtract 1, if FIN is in queue. */ /* Subtract 1, if FIN was received */
skb = skb_peek_tail(&sk->sk_receive_queue); if (answ && sock_flag(sk, SOCK_DONE))
if (answ && skb) answ--;
answ -= tcp_hdr(skb)->fin;
} else } else
answ = tp->urg_seq - tp->copied_seq; answ = tp->urg_seq - tp->copied_seq;
release_sock(sk); release_sock(sk);