diff mbox

tcp: take care of overlaps in tcp_try_coalesce()

Message ID 1337831497.3361.3888.camel@edumazet-glaptop
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet May 24, 2012, 3:51 a.m. UTC
From: Eric Dumazet <edumazet@google.com>

On Thu, 2012-05-24 at 00:21 -0300, Sergio Correia wrote:

> With your patch applied, the warning hasn't shown up in the last
> hours. Without it, dmesg would have been completely taken by them by
> now.
> I might be able to reproduce your test setup tomorrow, and if so, I will retest.
> 

I am going to send an official patch right now.

My own testings confirmed the bug origin and I am confident the patch is
OK.

Thanks !

[PATCH] tcp: take care of overlaps in tcp_try_coalesce()

Sergio Correia reported following warning :

WARNING: at net/ipv4/tcp.c:1301 tcp_cleanup_rbuf+0x4f/0x110()

WARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq),
     "cleanup rbuf bug: copied %X seq %X rcvnxt %X\n",
     tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);

It appears TCP coalescing, and more specifically commit b081f85c297
(net: implement tcp coalescing in tcp_queue_rcv()) should take care of
possible segment overlaps in receive queue. This was properly done in
the case of out_or_order_queue by the caller.

For example, segment at tail of queue have sequence 1000-2000, and we
add a segment with sequence 1500-2500.
This can happen in case of retransmits.

In this case, just don't do the coalescing.

Reported-by: Sergio Correia <lists@uece.net>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Tested-by: Sergio Correia <lists@uece.net>
---
 net/ipv4/tcp_input.c |    5 +++++
 1 file changed, 5 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller May 24, 2012, 4:27 a.m. UTC | #1
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 24 May 2012 05:51:37 +0200

> [PATCH] tcp: take care of overlaps in tcp_try_coalesce()
> 
> Sergio Correia reported following warning :
> 
> WARNING: at net/ipv4/tcp.c:1301 tcp_cleanup_rbuf+0x4f/0x110()
> 
> WARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq),
>      "cleanup rbuf bug: copied %X seq %X rcvnxt %X\n",
>      tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);
> 
> It appears TCP coalescing, and more specifically commit b081f85c297
> (net: implement tcp coalescing in tcp_queue_rcv()) should take care of
> possible segment overlaps in receive queue. This was properly done in
> the case of out_or_order_queue by the caller.
> 
> For example, segment at tail of queue have sequence 1000-2000, and we
> add a segment with sequence 1500-2500.
> This can happen in case of retransmits.
> 
> In this case, just don't do the coalescing.
> 
> Reported-by: Sergio Correia <lists@uece.net>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Tested-by: Sergio Correia <lists@uece.net>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index cfa2aa1..b224eb8 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4555,6 +4555,11 @@  static bool tcp_try_coalesce(struct sock *sk,
 
 	if (tcp_hdr(from)->fin)
 		return false;
+
+	/* Its possible this segment overlaps with prior segment in queue */
+	if (TCP_SKB_CB(from)->seq != TCP_SKB_CB(to)->end_seq)
+		return false;
+
 	if (!skb_try_coalesce(to, from, fragstolen, &delta))
 		return false;