Skip to contentSkip to conversation

Resend: TCP window tracking fixes

PATCH In review Phil Oester 2 participants 2 messages Feb 1, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Resend: TCP window tracking fixes

Resending two patches which have not yet made it to mainline, and which (IMO) are fairly important and should go in before 2.6.11.

1) retransmission handling -- window tracking needs to look at both seq numbers in determining whether a retransmission has occurred

http://lists.netfilter.org/pipermail/netfilter-devel/2005-January/018241.html

2) over-window handling -- window tracking should not adjust down the maximum seq number which it thinks a client has received -- the client may disagree with this number

http://lists.netfilter.org/pipermail/netfilter-devel/2005-January/018278.html

Patches attached below, comments welcomed.

Phil

include/linux/netfilter_ipv4/ip_conntrack_tcp.h +1 -0
diff -ru linux-orig/include/linux/netfilter_ipv4/ip_conntrack_tcp.h linux-new/include/linux/netfilter_ipv4/ip_conntrack_tcp.h
@@ -41,6 +41,7 @@
 	u_int8_t	retrans;	/* Number of retransmitted packets */
 	u_int8_t	last_index;	/* Index of the last packet */
 	u_int32_t	last_seq;	/* Last sequence number seen in dir */
+	u_int32_t	last_ack;	/* Last sequence number seen in opposite dir */
 	u_int32_t	last_end;	/* Last seq + len */
 };
 
net/ipv4/netfilter/ip_conntrack_proto_tcp.c +2 -0
diff -ru linux-orig/net/ipv4/netfilter/ip_conntrack_proto_tcp.c linux-new/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -665,11 +665,13 @@
 		if (*index == TCP_ACK_SET) {
 			if (state->last_dir == dir
 			    && state->last_seq == seq
+			    && state->last_ack == ack
 			    && state->last_end == end)
 				state->retrans++;
 			else {
 				state->last_dir = dir;
 				state->last_seq = seq;
+				state->last_ack = ack;
 				state->last_end = end;
 				state->retrans = 0;
 			}
net/ipv4/netfilter/ip_conntrack_proto_tcp.c +3 -4
diff -ru linux-orig/net/ipv4/netfilter/ip_conntrack_proto_tcp.c linux-testdellfw/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -622,7 +622,6 @@
 	/* Ignore data over the right edge of the receiver's window. */
 	if (after(end, sender->td_maxend) &&
 	    before(seq, sender->td_maxend)) {
-		end = sender->td_maxend;
 		if (*index == TCP_FIN_SET)
 			*index = TCP_ACK_SET;
 	}
@@ -691,9 +690,9 @@
 			after(seq, sender->td_end - receiver->td_maxwin - 1) ?
 			before(sack, receiver->td_end + 1) ?
 			after(ack, receiver->td_end - MAXACKWINDOW(sender)) ? "BUG"
-			: "ACK is under the lower bound (possibly overly delayed ACK)"
-			: "ACK is over the upper bound (ACKed data has never seen yet)"
-			: "SEQ is under the lower bound (retransmitted already ACKed data)"
+			: "ACK is under the lower bound (possible overly delayed ACK)"
+			: "ACK is over the upper bound (ACKed data not seen yet)"
+			: "SEQ is under the lower bound (already ACKed data retransmitted)"
 			: "SEQ is over the upper bound (over the window of the receiver)");
 
 		res = ip_ct_tcp_be_liberal && !tcph->rst;
#1 lore raw
Quoted 8 lines · Phil Oester

Resending two patches which have not yet made it to mainline, and which (IMO) are fairly important and should go in before 2.6.11.

1) retransmission handling -- window tracking needs to look at both seq numbers in determining whether a retransmission has occurred

http://lists.netfilter.org/pipermail/netfilter-devel/2005-January/018241.html

Quoted 8 lines

2) over-window handling -- window tracking should not adjust down the maximum seq number which it thinks a client has received -- the client may disagree with this number

http://lists.netfilter.org/pipermail/netfilter-devel/2005-January/018278.html

Patches attached below, comments welcomed.

I already have the retransmission handling patch queued, I'm just a little behind with pushing it to Dave. I would like to hear Jozsef's opinion before applying your second patch, he knows the code much better than me. Jozsef, does the second patch look ok to you ?

Regards
Patrick

Quoted 33 lines

Phil

------------------------------------------------------------------------

diff -ru linux-orig/net/ipv4/netfilter/ip_conntrack_proto_tcp.c linux-testdellfw/net/ipv4/netfilter/ip_conntrack_proto_tcp.c

net/ipv4/netfilter/ip_conntrack_proto_tcp.c +3 -4
@@ -622,7 +622,6 @@
 	/* Ignore data over the right edge of the receiver's window. */
 	if (after(end, sender->td_maxend) &&
 	    before(seq, sender->td_maxend)) {
-		end = sender->td_maxend;
 		if (*index == TCP_FIN_SET)
 			*index = TCP_ACK_SET;
 	}
@@ -691,9 +690,9 @@
 			after(seq, sender->td_end - receiver->td_maxwin - 1) ?
 			before(sack, receiver->td_end + 1) ?
 			after(ack, receiver->td_end - MAXACKWINDOW(sender)) ? "BUG"
-			: "ACK is under the lower bound (possibly overly delayed ACK)"
-			: "ACK is over the upper bound (ACKed data has never seen yet)"
-			: "SEQ is under the lower bound (retransmitted already ACKed data)"
+			: "ACK is under the lower bound (possible overly delayed ACK)"
+			: "ACK is over the upper bound (ACKed data not seen yet)"
+			: "SEQ is under the lower bound (already ACKed data retransmitted)"
 			: "SEQ is over the upper bound (over the window of the receiver)");
 
 		res = ip_ct_tcp_be_liberal && !tcph->rst;