]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: kill the fake untracked conntrack objects
authorFlorian Westphal <fw@strlen.de>
Fri, 14 Apr 2017 18:31:08 +0000 (20:31 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 15 Apr 2017 09:47:57 +0000 (11:47 +0200)
commite439cc17d64fb1a3c73b07d1c2c11f0586c4b171
tree08c09a05f63c6d146e0baf3f8f5f4752092c7622
parentcf63f1e7062d4f1032cde7b293a1ff94f7739d52
netfilter: kill the fake untracked conntrack objects

resurrect an old patch from Pablo Neira to remove the untracked objects.

Currently, there are four possible states of an skb wrt. conntrack.

1. No conntrack attached, ct is NULL.
2. Normal (kmem cache allocated) ct attached.
3. a template (kmalloc'd), not in any hash tables at any point in time
4. the 'untracked' conntrack, a percpu nf_conn object, tagged via
   IPS_UNTRACKED_BIT in ct->status.

Untracked is supposed to be identical to case 1.  It exists only
so users can check

-m conntrack --ctstate UNTRACKED vs.
-m conntrack --ctstate INVALID

e.g. attempts to set connmark on INVALID or UNTRACKED conntracks is
supposed to be a no-op.

Thus currently we need to check
 ct == NULL || nf_ct_is_untracked(ct)

in a lot of places in order to avoid altering untracked objects.

The other consequence of the percpu untracked object is that all
-j NOTRACK (and, later, kfree_skb of such skbs) result in an atomic op
(inc/dec the untracked conntracks refcount).

This adds a new kernel-private ctinfo state, IP_CT_UNTRACKED, to
make the distinction instead.

The (few) places that care about packet invalid (ct is NULL) vs.
packet untracked now need to test ct == NULL vs. ctinfo == IP_CT_UNTRACKED,
but all other places can omit the nf_ct_is_untracked() check.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 files changed:
include/net/ip_vs.h
include/net/netfilter/nf_conntrack.h
include/uapi/linux/netfilter/nf_conntrack_common.h
net/ipv4/netfilter/nf_dup_ipv4.c
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
net/ipv6/netfilter/nf_dup_ipv6.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_nat_core.c
net/netfilter/nft_ct.c
net/netfilter/xt_CT.c
net/netfilter/xt_conntrack.c
net/netfilter/xt_state.c