Skip to content

Commit 72d4d3e

Browse files
Jozsef Kadlecsikummakynes
authored andcommitted
netfilter: Fix handling simultaneous open in TCP conntrack
Dominique Martinet reported a TCP hang problem when simultaneous open was used. The problem is that the tcp_conntracks state table is not smart enough to handle the case. The state table could be fixed by introducing a new state, but that would require more lines of code compared to this patch, due to the required backward compatibility with ctnetlink. Signed-off-by: Jozsef Kadlecsik <[email protected]> Reported-by: Dominique Martinet <[email protected]> Tested-by: Dominique Martinet <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 25eb0ea commit 72d4d3e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/uapi/linux/netfilter/nf_conntrack_tcp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ enum tcp_conntrack {
4646
/* Marks possibility for expected RFC5961 challenge ACK */
4747
#define IP_CT_EXP_CHALLENGE_ACK 0x40
4848

49+
/* Simultaneous open initialized */
50+
#define IP_CT_TCP_SIMULTANEOUS_OPEN 0x80
51+
4952
struct nf_ct_tcp_flags {
5053
__u8 flags;
5154
__u8 mask;

net/netfilter/nf_conntrack_proto_tcp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,17 @@ static int tcp_packet(struct nf_conn *ct,
981981
return NF_ACCEPT; /* Don't change state */
982982
}
983983
break;
984+
case TCP_CONNTRACK_SYN_SENT2:
985+
/* tcp_conntracks table is not smart enough to handle
986+
* simultaneous open.
987+
*/
988+
ct->proto.tcp.last_flags |= IP_CT_TCP_SIMULTANEOUS_OPEN;
989+
break;
990+
case TCP_CONNTRACK_SYN_RECV:
991+
if (dir == IP_CT_DIR_REPLY && index == TCP_ACK_SET &&
992+
ct->proto.tcp.last_flags & IP_CT_TCP_SIMULTANEOUS_OPEN)
993+
new_state = TCP_CONNTRACK_ESTABLISHED;
994+
break;
984995
case TCP_CONNTRACK_CLOSE:
985996
if (index == TCP_RST_SET
986997
&& (ct->proto.tcp.seen[!dir].flags & IP_CT_TCP_FLAG_MAXACK_SET)

0 commit comments

Comments
 (0)