netfilter: conntrack: ignore overly delayed tcp packets
authorFlorian Westphal <fw@strlen.de>
Fri, 26 Aug 2022 13:32:25 +0000 (15:32 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 7 Sep 2022 13:43:51 +0000 (15:43 +0200)
commit6e250dcbff1d3ce347b8294e4ec6da96a2cecdb5
tree006228ebc0e805fc52037d21d5c8f1cd1e6e4f16
parentd9a6f0d0df1899ff9086a57abc600e414f4b8cdd
netfilter: conntrack: ignore overly delayed tcp packets

If 'nf_conntrack_tcp_loose' is off (the default), tcp packets that are
outside of the current window are marked as INVALID.

nf/iptables rulesets often drop such packets via 'ct state invalid' or
similar checks.

For overly delayed acks, this can be a nuisance if such 'invalid' packets
are also logged.

Since they are not invalid in a strict sense, just ignore them, i.e.
conntrack won't extend timeout or change state so that they do not match
invalid state rules anymore.

This also avoids unwantend connection stalls in case conntrack considers
retransmission (of data that did not reach the peer) as too old.

The else branch of the conditional becomes obsolete.
Next patch will reformant the now always-true if condition.

The existing workaround for data that exceeds the calculated receive
window is adjusted to use the 'ignore' state so that these packets do
not refresh the timeout or change state other than updating ->td_end.

Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_conntrack_proto_tcp.c