[patch] TCP -> retrans_collapse doesn't update packets_out

Andrea Arcangeli (andrea@e-mind.com)
Wed, 10 Mar 1999 14:23:18 +0100 (CET)


I think I fixed a bug in the retrans path of the TCP stack. Here the
patch against 2.2.3:

Index: tcp_output.c
===================================================================
RCS file: /var/cvs/linux/net/ipv4/tcp_output.c,v
retrieving revision 1.1.2.14
diff -u -r1.1.2.14 tcp_output.c
--- tcp_output.c 1999/03/09 01:24:08 1.1.2.14
+++ linux/net/ipv4/tcp_output.c 1999/03/10 13:07:36
@@ -451,7 +451,7 @@
}

/* Attempt to collapse two adjacent SKB's during retransmission. */
-static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int mss_now)
+static int tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int mss_now)
{
struct sk_buff *next_skb = skb->next;

@@ -464,11 +464,11 @@

/* Punt if the first SKB has URG set. */
if(flags & TCPCB_FLAG_URG)
- return;
+ return -1;

/* Also punt if next skb has been SACK'd. */
if(TCP_SKB_CB(next_skb)->sacked & TCPCB_SACKED_ACKED)
- return;
+ return -1;

/* Punt if not enough space exists in the first SKB for
* the data in the second, or the total combined payload
@@ -476,7 +476,7 @@
*/
if ((next_skb_size > skb_tailroom(skb)) ||
((skb_size + next_skb_size) > mss_now))
- return;
+ return -1;

/* Ok. We will be able to collapse the packet. */
__skb_unlink(next_skb, next_skb->list);
@@ -510,7 +510,9 @@
*/
kfree_skb(next_skb);
sk->tp_pinfo.af_tcp.packets_out--;
+ return 0;
}
+ return -1;
}

/* Do a simple retransmit without using the backoff mechanisms in
@@ -575,7 +577,8 @@
(skb->next != tp->send_head) &&
(skb->next != (struct sk_buff *)&sk->write_queue) &&
(sysctl_tcp_retrans_collapse != 0))
- tcp_retrans_try_collapse(sk, skb, cur_mss);
+ if (!tcp_retrans_try_collapse(sk, skb, cur_mss))
+ tp->packets_out--;

if(tp->af_specific->rebuild_header(sk))
return 1; /* Routing failure or similar. */

Risking to have packets_out out of sync looks like a major problem to me.

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/