Skip to contentSkip to conversation

Fix RST handling in ip_conntrack_proto_tcp.c

PATCH In review Martin Josefsson 3 participants 5 messages Dec 31, 2004 – Jan 2, 2005

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

PATCH 1/1 Fix RST handling in ip_conntrack_proto_tcp.c

Hi Jozsef

Your latest patch contained a change to the RST handling. The change was that an RST is ignored if the previous packet was an ACK. This is happens all the time. I know it was intended as a fix for the SYN - ACK probe - RST sequence but it breaks normal usage. The problem is that connections that end with RST never get their state changed and are left in ESTABLISHED state with a large timeout.

The patch below adds a check for
!test_bit(IPS_ASSURED_BIT, &conntrack->status) so your change will only be active for unassured connections. Maybe you have a better idea for how to fix both cases.

This patch has been tested by a user that reported the problem on irc and it fixes the problem for him. I'm also running it on a machine with lots of traffic and it fixes the problem for me as well.

Please make sure something that fixes the problem is submitted fairly quickly.

<hint> A tcp-state/windowtracking testcase for nfsim would be great </hint> :)

net/ipv4/netfilter/ip_conntrack_proto_tcp.c renamed from net/ipv4/netfilter/ip_conntrack_proto_tcp.c.orig +2 -1
@@ -906,7 +906,8 @@ static int tcp_packet(struct ip_conntrac
 		if (index == TCP_RST_SET
 		    && ((test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)
 		         && conntrack->proto.tcp.last_index <= TCP_SYNACK_SET)
-		        || conntrack->proto.tcp.last_index == TCP_ACK_SET)
+		        || (!test_bit(IPS_ASSURED_BIT, &conntrack->status)
+			 && conntrack->proto.tcp.last_index == TCP_ACK_SET))
 		    && after(ntohl(th->ack_seq),
 		    	     conntrack->proto.tcp.last_seq)) {
 			/* Ignore RST closing down invalid SYN or ACK
Signature · 1 line
/Martin
#1 lore raw

Hi Martin,

Quoted 6 lines · Martin Josefsson

Your latest patch contained a change to the RST handling. The change was that an RST is ignored if the previous packet was an ACK. This is happens all the time. I know it was intended as a fix for the SYN - ACK probe - RST sequence but it breaks normal usage. The problem is that connections that end with RST never get their state changed and are left in ESTABLISHED state with a large timeout.

Ouch!

Quoted 11 lines

The patch below adds a check for
!test_bit(IPS_ASSURED_BIT, &conntrack->status) so your change will only be active for unassured connections. Maybe you have a better idea for how to fix both cases.

This patch has been tested by a user that reported the problem on irc and it fixes the problem for him. I'm also running it on a machine with lots of traffic and it fixes the problem for me as well.

Please make sure something that fixes the problem is submitted fairly quickly.

I think your patch should be submitted immediately. The introduced bug is too bad to leave it linger on.

Quoted 2 lines

<hint> A tcp-state/windowtracking testcase for nfsim would be great </hint> :)

Yep, I got Rusty's message as well :-) Time to dig out the initial tests from the old cvs and convert them to nfsim with new cases added.

net/ipv4/netfilter/ip_conntrack_proto_tcp.c static int tcp_packet(struct ip_conntrac · line 913

Quoted 13 lines
net/ipv4/netfilter/ip_conntrack_proto_tcp.c renamed from net/ipv4/netfilter/ip_conntrack_proto_tcp.c.orig +2 -1
@@ -906,7 +906,8 @@ static int tcp_packet(struct ip_conntrac
 		if (index == TCP_RST_SET
 		    && ((test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)
 		         && conntrack->proto.tcp.last_index <= TCP_SYNACK_SET)
-		        || conntrack->proto.tcp.last_index == TCP_ACK_SET)
+		        || (!test_bit(IPS_ASSURED_BIT, &conntrack->status)
+			 && conntrack->proto.tcp.last_index == TCP_ACK_SET))
 		    && after(ntohl(th->ack_seq),
 		    	     conntrack->proto.tcp.last_seq)) {
 			/* Ignore RST closing down invalid SYN or ACK

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#2 lore raw
Quoted 1 line · Jozsef Kadlecsik

Hi Martin,

Hi Jozsef

Quoted 1 line

Ouch!

I agree :)

Quoted 5 lines
Quoted 2 lines

Please make sure something that fixes the problem is submitted fairly quickly.

I think your patch should be submitted immediately. The introduced bug is too bad to leave it linger on.

I'll submit it to Andrew since Davem is on vacation.

Quoted 5 lines
Quoted 2 lines

<hint> A tcp-state/windowtracking testcase for nfsim would be great </hint> :)

Yep, I got Rusty's message as well :-) Time to dig out the initial tests from the old cvs and convert them to nfsim with new cases added.

:) We need more testcases badly, for all sorts of things.

Signature · 1 line
/Martin
#3 lore raw
Quoted 8 lines · Martin Josefsson
Quoted 3 lines · Jozsef Kadlecsik

I think your patch should be submitted immediately. The introduced bug is too bad to leave it linger on.

I'll submit it to Andrew since Davem is on vacation.

The patch hasn't shown up in Linus's tree yet. I'm going to add it to my tree and push it to Dave with the other patches if it didn't show up by Tuesday.

Regards
Patrick

#4 lore raw
Quoted 5 lines · Patrick McHardy
Quoted 2 lines

I'll submit it to Andrew since Davem is on vacation.

The patch hasn't shown up in Linus's tree yet. I'm going to add it to my tree and push it to Dave with the other patches if it didn't show up by Tuesday.

Great, thanks

Signature · 1 line
/Martin