netfilter: conncount: normalize tuple and zone on successful ct lookup

When get_ct_or_tuple_from_skb() falls back to looking for a connection
via nf_conntrack_find_get(), a successful lookup sets ct but leaves
tuple and zone unupdated.

If the packet belongs to a reply flow, tuple will remain in the reply
direction. As conncount relies on the original direction tuple to count
the connections consistenly, passing an unnormalized reply tuple could
lead to problems.

Fix this by making sure that tuple and zone are normalized.

Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Fernando Fernandez Mancera
2026-07-27 21:41:29 +02:00
committed by Pablo Neira Ayuso
parent 2fbade6624
commit e53932f0e5

View File

@@ -158,6 +158,8 @@ static bool get_ct_or_tuple_from_skb(struct net *net,
return true;
found_ct = nf_ct_tuplehash_to_ctrack(h);
*tuple = found_ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
*zone = nf_ct_zone(found_ct);
*refcounted = true;
*ct = found_ct;