: Fix RB-tree comparisons
Subsystems (3)
David Miller
maintainerPATCH 1/1 : Fix RB-tree comparisons
While reviewing Ilpo's lost marking code I noticed that the RB-tree code was doing raw comparisons on sequence numbers which is always wrong.
I checked the following into net-2.6.22 to cure that:
[TCP]: Fix sequence number comparisons in RB-tree code.
Need to use after(), before(), etc. to handle wrapping correctly.
Signed-off-by David S. Miller <[email protected]>
include/net/tcp.h +4 -4
@@ -1233,9 +1233,9 @@ static inline struct sk_buff *tcp_write_queue_find(struct sock *sk, __u32 seq)while (rb_node) { struct sk_buff *tmp = rb_entry(rb_node,struct sk_buff,rb); -if (TCP_SKB_CB (tmp)->end_seq > seq) { +if (after (TCP_SKB_CB (tmp)->end_seq, seq)) { skb = tmp; -if (TCP_SKB_CB (tmp)->seq <= seq) +if (!after (TCP_SKB_CB (tmp)->seq, seq))break ; rb_node = rb_node->rb_left; }else
@@ -1257,8 +1257,8 @@ static inline void tcp_rb_insert(struct sk_buff *skb, struct rb_root *root) rb_parent = *rb_link; tmp = rb_entry(rb_parent,struct sk_buff,rb); -if (TCP_SKB_CB (tmp)->end_seq > seq) { -BUG_ON (TCP_SKB_CB (tmp)->seq <= seq); +if (after (TCP_SKB_CB (tmp)->end_seq, seq)) { +BUG_ON (!after (TCP_SKB_CB (tmp)->seq, seq)); rb_link = &rb_parent->rb_left; }else { rb_link = &rb_parent->rb_right;