netfilter: conntrack: prepare tcp_in_window for ternary return value
authorFlorian Westphal <fw@strlen.de>
Fri, 26 Aug 2022 13:32:24 +0000 (15:32 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 7 Sep 2022 13:43:51 +0000 (15:43 +0200)
commitd9a6f0d0df1899ff9086a57abc600e414f4b8cdd
treef2470ad7b4cd6b21b2b22049d0163d0b143ab2bd
parent016eb59012b576f5a7b7b415d757717dc8cb3c6b
netfilter: conntrack: prepare tcp_in_window for ternary return value

tcp_in_window returns true if the packet is in window and false if it is
not.

If its outside of window, packet will be treated as INVALID.

There are corner cases where the packet should still be tracked, because
rulesets may drop or log such packets, even though they can occur during
normal operation, such as overly delayed acks.

In extreme cases, connection may hang forever because conntrack state
differs from real state.

There is no retransmission for ACKs.

In case of ACK loss after conntrack processing, its possible that a
connection can be stuck because the actual retransmits are considered
stale ("SEQ is under the lower bound (already ACKed data
retransmitted)".

The problem is made worse by carrier-grade-nat which can also result
in stale packets from old connections to get treated as 'recent' packets
in conntrack (it doesn't support tcp timestamps at this time).

Prepare tcp_in_window() to return an enum that tells the desired
action (in-window/accept, bogus/drop).

A third action (accept the packet as in-window, but do not change
state) is added in a followup patch.

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