tcp: provide more information on the tcp receive_queue bugs

The addition of rcv_nxt allows to discern whether the skb
was out of place or tp->copied. Also catch fancy combination
of flags if necessary (sadly we might miss the actual causer
flags as it might have already returned).

Btw, we perhaps would want to forward copied_seq in
somewhere or otherwise we might have some nice loop with
WARN stuff within but where to do that safely I don't
know at this stage until more is known (but it is not
made significantly worse by this patch).

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ilpo Järvinen 2009-11-13 13:56:33 -08:00 коммит произвёл David S. Miller
Родитель d01032e4fd
Коммит d792c1006f
1 изменённых файлов: 12 добавлений и 7 удалений

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

@ -1183,7 +1183,9 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied)
#if TCP_DEBUG #if TCP_DEBUG
struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); struct sk_buff *skb = skb_peek(&sk->sk_receive_queue);
WARN_ON(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)); WARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq),
KERN_INFO "cleanup rbuf bug: copied %X seq %X rcvnxt %X\n",
tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);
#endif #endif
if (inet_csk_ack_scheduled(sk)) { if (inet_csk_ack_scheduled(sk)) {
@ -1430,11 +1432,13 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
/* Now that we have two receive queues this /* Now that we have two receive queues this
* shouldn't happen. * shouldn't happen.
*/ */
if (before(*seq, TCP_SKB_CB(skb)->seq)) { if (WARN(before(*seq, TCP_SKB_CB(skb)->seq),
printk(KERN_INFO "recvmsg bug: copied %X " KERN_INFO "recvmsg bug: copied %X "
"seq %X\n", *seq, TCP_SKB_CB(skb)->seq); "seq %X rcvnxt %X fl %X\n", *seq,
TCP_SKB_CB(skb)->seq, tp->rcv_nxt,
flags))
break; break;
}
offset = *seq - TCP_SKB_CB(skb)->seq; offset = *seq - TCP_SKB_CB(skb)->seq;
if (tcp_hdr(skb)->syn) if (tcp_hdr(skb)->syn)
offset--; offset--;
@ -1443,8 +1447,9 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (tcp_hdr(skb)->fin) if (tcp_hdr(skb)->fin)
goto found_fin_ok; goto found_fin_ok;
WARN(!(flags & MSG_PEEK), KERN_INFO "recvmsg bug 2: " WARN(!(flags & MSG_PEEK), KERN_INFO "recvmsg bug 2: "
"copied %X seq %X\n", *seq, "copied %X seq %X rcvnxt %X fl %X\n",
TCP_SKB_CB(skb)->seq); *seq, TCP_SKB_CB(skb)->seq,
tp->rcv_nxt, flags);
} }
/* Well, if we have backlog, try to process it now yet. */ /* Well, if we have backlog, try to process it now yet. */