Skip to content

Commit f2dd495

Browse files
committed
netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options
Do not reset IP_CT_TCP_FLAG_BE_LIBERAL flag in out-of-sync scenarios coming before the TCP window tracking, otherwise such connections will fail in the window check. Update tcp_options() to leave this flag in place and add a new helper function to reset the tcp window state. Based on patch from Sven Auhagen. Fixes: c4832c7 ("netfilter: nf_ct_tcp: improve out-of-sync situation in TCP tracking") Tested-by: Sven Auhagen <sven.auhagen@voleatech.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent d645552 commit f2dd495

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

net/netfilter/nf_conntrack_proto_tcp.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ static void tcp_options(const struct sk_buff *skb,
341341
if (!ptr)
342342
return;
343343

344-
state->td_scale =
345-
state->flags = 0;
344+
state->td_scale = 0;
345+
state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL;
346346

347347
while (length > 0) {
348348
int opcode=*ptr++;
@@ -862,6 +862,16 @@ static bool tcp_can_early_drop(const struct nf_conn *ct)
862862
return false;
863863
}
864864

865+
static void nf_ct_tcp_state_reset(struct ip_ct_tcp_state *state)
866+
{
867+
state->td_end = 0;
868+
state->td_maxend = 0;
869+
state->td_maxwin = 0;
870+
state->td_maxack = 0;
871+
state->td_scale = 0;
872+
state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL;
873+
}
874+
865875
/* Returns verdict for packet, or -1 for invalid. */
866876
int nf_conntrack_tcp_packet(struct nf_conn *ct,
867877
struct sk_buff *skb,
@@ -968,8 +978,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
968978
ct->proto.tcp.last_flags &= ~IP_CT_EXP_CHALLENGE_ACK;
969979
ct->proto.tcp.seen[ct->proto.tcp.last_dir].flags =
970980
ct->proto.tcp.last_flags;
971-
memset(&ct->proto.tcp.seen[dir], 0,
972-
sizeof(struct ip_ct_tcp_state));
981+
nf_ct_tcp_state_reset(&ct->proto.tcp.seen[dir]);
973982
break;
974983
}
975984
ct->proto.tcp.last_index = index;

0 commit comments

Comments
 (0)