Skip to contentSkip to conversation

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

PATCH Applied Florian Westphal 2 participants 2 messages Jan 13, 2022 – Jan 20, 2022

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: conntrack: don't increment invalid counter on NF_REPEAT

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 56a62e2218f5 ("netfilter: conntrack: fix NF_REPEAT handling")
---
 net/netfilter/nf_conntrack_core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_core.c +5 -3
index 894a325d39f2..d6aa5b47031e 100644
@@ -1924,15 +1924,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");
 		nf_ct_put(ct);
 		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
 		 * closed/aborted connection. We have to go back and create a
 		 * fresh conntrack.
 		 */
 		if (ret == -NF_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;
 		goto out;
 	}
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Florian Westphal

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.

Applied to nf, thanks