OSDN Git Service

netfilter: conntrack: remove l4proto destroy hook
authorFlorian Westphal <fw@strlen.de>
Tue, 15 Jan 2019 21:03:46 +0000 (22:03 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 18 Jan 2019 14:02:34 +0000 (15:02 +0100)
Only one user (gre), add a direct call and remove this facility.

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

index d5909e5..5d1419a 100644 (file)
@@ -27,9 +27,6 @@ struct nf_conntrack_l4proto {
        /* protoinfo nlattr size, closes a hole */
        u16 nlattr_size;
 
-       /* Called when a conntrack entry is destroyed */
-       void (*destroy)(struct nf_conn *ct);
-
        /* called by gc worker if table is full */
        bool (*can_early_drop)(const struct nf_conn *ct);
 
index 728d2b5..52e6c5c 100644 (file)
@@ -524,11 +524,18 @@ void nf_ct_tmpl_free(struct nf_conn *tmpl)
 }
 EXPORT_SYMBOL_GPL(nf_ct_tmpl_free);
 
+static void destroy_gre_conntrack(struct nf_conn *ct)
+{
+       struct nf_conn *master = ct->master;
+
+       if (master)
+               nf_ct_gre_keymap_destroy(master);
+}
+
 static void
 destroy_conntrack(struct nf_conntrack *nfct)
 {
        struct nf_conn *ct = (struct nf_conn *)nfct;
-       const struct nf_conntrack_l4proto *l4proto;
 
        pr_debug("destroy_conntrack(%p)\n", ct);
        WARN_ON(atomic_read(&nfct->use) != 0);
@@ -537,9 +544,9 @@ destroy_conntrack(struct nf_conntrack *nfct)
                nf_ct_tmpl_free(ct);
                return;
        }
-       l4proto = __nf_ct_l4proto_find(nf_ct_protonum(ct));
-       if (l4proto->destroy)
-               l4proto->destroy(ct);
+
+       if (unlikely(nf_ct_protonum(ct) == IPPROTO_GRE))
+               destroy_gre_conntrack(ct);
 
        local_bh_disable();
        /* Expectations will have been removed in clean_from_lists,
index fa765d2..ee9ab10 100644 (file)
@@ -249,19 +249,6 @@ int nf_conntrack_gre_packet(struct nf_conn *ct,
        return NF_ACCEPT;
 }
 
-/* Called when a conntrack entry has already been removed from the hashes
- * and is about to be deleted from memory */
-static void gre_destroy(struct nf_conn *ct)
-{
-       struct nf_conn *master = ct->master;
-       pr_debug(" entering\n");
-
-       if (!master)
-               pr_debug("no master !?!\n");
-       else
-               nf_ct_gre_keymap_destroy(master);
-}
-
 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
 
 #include <linux/netfilter/nfnetlink.h>
@@ -329,7 +316,6 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre = {
 #ifdef CONFIG_NF_CONNTRACK_PROCFS
        .print_conntrack = gre_print_conntrack,
 #endif
-       .destroy         = gre_destroy,
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
        .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
        .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,