DORMANTno replies

[PATCH]: Fix RB-tree comparisons

From: David Miller <davem@davemloft.net>
Date: 2007-03-09 05:20:14
Subsystem: networking [general], networking [tcp], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neal Cardwell, Linus Torvalds

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 <davem@davemloft.net>
diff --git a/include/net/tcp.h b/include/net/tcp.h
index b94debb..813fa8b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -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;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help