netfilter: remove nf_ct_unconfirmed_destroy helper
authorFlorian Westphal <fw@strlen.de>
Mon, 11 Apr 2022 11:01:20 +0000 (13:01 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 13 May 2022 16:52:16 +0000 (18:52 +0200)
This helper tags connections not yet in the conntrack table as
dying.  These nf_conn entries will be dropped instead when the
core attempts to insert them from the input or postrouting
'confirm' hook.

After the previous change, the entries get unlinked from the
list earlier, so that by the time the actual exit hook runs,
new connections no longer have a timeout policy assigned.

Its enough to walk the hashtable instead.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_conntrack.h
net/netfilter/nf_conntrack_core.c
net/netfilter/nfnetlink_cttimeout.c

index 28672a94449974d501fcf334942a264cda4d5ff6..f60212244b13f6262648ebf0561bf8dacbec4041 100644 (file)
@@ -237,9 +237,6 @@ static inline bool nf_ct_kill(struct nf_conn *ct)
        return nf_ct_delete(ct, 0, 0);
 }
 
-/* Set all unconfirmed conntrack as dying */
-void nf_ct_unconfirmed_destroy(struct net *);
-
 /* Iterate over all conntracks: if iter returns true, it's deleted. */
 void nf_ct_iterate_cleanup_net(struct net *net,
                               int (*iter)(struct nf_conn *i, void *data),
index 9010b6e5a072e0fa8854eef9ff084b9055106694..b3cc318ceb4526eb89f1bce88168f64fd3e4c080 100644 (file)
@@ -2431,20 +2431,6 @@ __nf_ct_unconfirmed_destroy(struct net *net)
        }
 }
 
-void nf_ct_unconfirmed_destroy(struct net *net)
-{
-       struct nf_conntrack_net *cnet = nf_ct_pernet(net);
-
-       might_sleep();
-
-       if (atomic_read(&cnet->count) > 0) {
-               __nf_ct_unconfirmed_destroy(net);
-               nf_queue_nf_hook_drop(net);
-               synchronize_net();
-       }
-}
-EXPORT_SYMBOL_GPL(nf_ct_unconfirmed_destroy);
-
 void nf_ct_iterate_cleanup_net(struct net *net,
                               int (*iter)(struct nf_conn *i, void *data),
                               void *data, u32 portid, int report)
index 83fa15c4193cd07ca7177db5c2fe3be9145ec54f..f366b8187915576cfde8ec21457e68000c3a9125 100644 (file)
@@ -608,7 +608,9 @@ static void __net_exit cttimeout_net_exit(struct net *net)
        struct nfct_timeout_pernet *pernet = nfct_timeout_pernet(net);
        struct ctnl_timeout *cur, *tmp;
 
-       nf_ct_unconfirmed_destroy(net);
+       if (list_empty(&pernet->nfct_timeout_freelist))
+               return;
+
        nf_ct_untimeout(net, NULL);
 
        list_for_each_entry_safe(cur, tmp, &pernet->nfct_timeout_freelist, head) {