Skip to content

Commit

Permalink
tcp: fix loop in ofo handling code and reduce its complexity
Browse files Browse the repository at this point in the history
Somewhat luckily, I was looking into these parts with very fine
comb because I've made somewhat similar changes on the same
area (conflicts that arose weren't that lucky though). The loop
was very much overengineered recently in commit 9152194
(tcp: Use SKB queue and list helpers instead of doing it
by-hand), while it basically just wants to know if there are
skbs after 'skb'.

Also it got broken because skb1 = skb->next got translated into
skb1 = skb1->next (though abstracted) improperly. Note that
'skb1' is pointing to previous sk_buff than skb or NULL if at
head. Two things went wrong:
- We'll kfree 'skb' on the first iteration instead of the
  skbuff following 'skb' (it would require required SACK reneging
  to recover I think).
- The list head case where 'skb1' is NULL is checked too early
  and the loop won't execute whereas it previously did.

Conclusion, mostly revert the recent changes which makes the
cset very messy looking but using proper accessor in the
previous-like version.

The effective changes against the original can be viewed with:
  git-diff 9152194^ \
		net/ipv4/tcp_input.c | sed -n -e '57,70 p'

Signed-off-by: Ilpo Järvinen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ij1 authored and davem330 committed May 29, 2009
1 parent 5d4e039 commit 2df9001
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -4481,26 +4481,20 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
__skb_queue_after(&tp->out_of_order_queue, skb1, skb);

/* And clean segments covered by new one as whole. */
if (skb1 && !skb_queue_is_last(&tp->out_of_order_queue, skb1)) {
struct sk_buff *n;
while (!skb_queue_is_last(&tp->out_of_order_queue, skb)) {
skb1 = skb_queue_next(&tp->out_of_order_queue, skb);

skb1 = skb_queue_next(&tp->out_of_order_queue, skb1);
skb_queue_walk_from_safe(&tp->out_of_order_queue,
skb1, n) {
if (!after(end_seq, TCP_SKB_CB(skb1)->seq))
break;
if (before(end_seq,
TCP_SKB_CB(skb1)->end_seq)) {
tcp_dsack_extend(sk,
TCP_SKB_CB(skb1)->seq,
end_seq);
break;
}
__skb_unlink(skb1, &tp->out_of_order_queue);
if (!after(end_seq, TCP_SKB_CB(skb1)->seq))
break;
if (before(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
TCP_SKB_CB(skb1)->end_seq);
__kfree_skb(skb1);
end_seq);
break;
}
__skb_unlink(skb1, &tp->out_of_order_queue);
tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
TCP_SKB_CB(skb1)->end_seq);
__kfree_skb(skb1);
}

add_sack:
Expand Down

0 comments on commit 2df9001

Please sign in to comment.