Skip to content

Commit 1ca7ee3

Browse files
edumazetdavem330
authored andcommitted
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 b081f85 (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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e49cc0d commit 1ca7ee3

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎net/ipv4/tcp_input.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,6 +4555,11 @@ static bool tcp_try_coalesce(struct sock *sk,
45554555

45564556
if (tcp_hdr(from)->fin)
45574557
return false;
4558+
4559+
/* Its possible this segment overlaps with prior segment in queue */
4560+
if (TCP_SKB_CB(from)->seq != TCP_SKB_CB(to)->end_seq)
4561+
return false;
4562+
45584563
if (!skb_try_coalesce(to, from, fragstolen, &delta))
45594564
return false;
45604565

0 commit comments

Comments
 (0)