netfilter: conntrack: don't increment invalid counter on NF_REPEAT

[ Upstream commit 830af2eba40327abec64325a5b08b1e85c37a2e0 ]

The packet isn't invalid, REPEAT means we're trying again after cleaning
out a stale connection, e.g. via tcp tracker.

This caused increases of invalid stat counter in a test case involving
frequent connection reuse, even though no packet is actually invalid.

Fixes: 56a62e2218 ("netfilter: conntrack: fix NF_REPEAT handling")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Florian Westphal 2022-01-13 21:37:58 +01:00 committed by Greg Kroah-Hartman
parent 129c71829d
commit 1af995c98b

View File

@ -1832,15 +1832,17 @@ nf_conntrack_in(struct sk_buff *skb, const struct nf_hook_state *state)
pr_debug("nf_conntrack_in: Can't track with proto module\n"); pr_debug("nf_conntrack_in: Can't track with proto module\n");
nf_conntrack_put(&ct->ct_general); nf_conntrack_put(&ct->ct_general);
skb->_nfct = 0; skb->_nfct = 0;
NF_CT_STAT_INC_ATOMIC(state->net, invalid);
if (ret == -NF_DROP)
NF_CT_STAT_INC_ATOMIC(state->net, drop);
/* Special case: TCP tracker reports an attempt to reopen a /* Special case: TCP tracker reports an attempt to reopen a
* closed/aborted connection. We have to go back and create a * closed/aborted connection. We have to go back and create a
* fresh conntrack. * fresh conntrack.
*/ */
if (ret == -NF_REPEAT) if (ret == -NF_REPEAT)
goto repeat; goto repeat;
NF_CT_STAT_INC_ATOMIC(state->net, invalid);
if (ret == -NF_DROP)
NF_CT_STAT_INC_ATOMIC(state->net, drop);
ret = -ret; ret = -ret;
goto out; goto out;
} }