]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
[NETFILTER]: nf_conntrack: kill destroy() in struct nf_conntrack for diet
authorYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Fri, 23 Mar 2007 18:17:27 +0000 (11:17 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:27:45 +0000 (22:27 -0700)
The destructor per conntrack is unnecessary, then this replaces it with
system wide destructor.

Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netfilter.h
include/linux/skbuff.h
net/netfilter/core.c
net/netfilter/nf_conntrack_core.c

index 4777f1b619ce17a2834eb5f545e5cae1a1d5b2aa..10b5c6275706585f56131f695c9faad2e86fe005 100644 (file)
@@ -393,6 +393,7 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) {}
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *);
 extern void nf_ct_attach(struct sk_buff *, struct sk_buff *);
+extern void (*nf_ct_destroy)(struct nf_conntrack *);
 #else
 static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
 #endif
index 0bedf53848506c474888a2f649c413f40ab3c720..37247901ebd2ffe9f8c5fde0987210a565eacdd8 100644 (file)
@@ -90,7 +90,6 @@ struct net_device;
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 struct nf_conntrack {
        atomic_t use;
-       void (*destroy)(struct nf_conntrack *);
 };
 #endif
 
@@ -1556,10 +1555,11 @@ static inline unsigned int skb_checksum_complete(struct sk_buff *skb)
 }
 
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+extern void nf_conntrack_destroy(struct nf_conntrack *nfct);
 static inline void nf_conntrack_put(struct nf_conntrack *nfct)
 {
        if (nfct && atomic_dec_and_test(&nfct->use))
-               nfct->destroy(nfct);
+               nf_conntrack_destroy(nfct);
 }
 static inline void nf_conntrack_get(struct nf_conntrack *nfct)
 {
index fe5f22df620c5dae870d5c0f1f27c37622fa62f9..a84478ee2ded4c4b4a6888794ff05b70a3204cdc 100644 (file)
@@ -260,7 +260,22 @@ void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb)
        }
 }
 EXPORT_SYMBOL(nf_ct_attach);
-#endif
+
+void (*nf_ct_destroy)(struct nf_conntrack *);
+EXPORT_SYMBOL(nf_ct_destroy);
+
+void nf_conntrack_destroy(struct nf_conntrack *nfct)
+{
+       void (*destroy)(struct nf_conntrack *);
+
+       rcu_read_lock();
+       destroy = rcu_dereference(nf_ct_destroy);
+       BUG_ON(destroy == NULL);
+       destroy(nfct);
+       rcu_read_unlock();
+}
+EXPORT_SYMBOL(nf_conntrack_destroy);
+#endif /* CONFIG_NF_CONNTRACK */
 
 #ifdef CONFIG_PROC_FS
 struct proc_dir_entry *proc_net_netfilter;
index 6f2aac1d01afd724123b2a405b89300aea663b4f..e132c8ae87840306f41f9a56043fd543ffeaa7f4 100644 (file)
@@ -616,7 +616,6 @@ __nf_conntrack_alloc(const struct nf_conntrack_tuple *orig,
        memset(conntrack, 0, nf_ct_cache[features].size);
        conntrack->features = features;
        atomic_set(&conntrack->ct_general.use, 1);
-       conntrack->ct_general.destroy = destroy_conntrack;
        conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig;
        conntrack->tuplehash[IP_CT_DIR_REPLY].tuple = *repl;
        /* Don't set timer yet: wait for confirmation */
@@ -1122,6 +1121,8 @@ void nf_conntrack_cleanup(void)
        while (atomic_read(&nf_conntrack_untracked.ct_general.use) > 1)
                schedule();
 
+       rcu_assign_pointer(nf_ct_destroy, NULL);
+
        for (i = 0; i < NF_CT_F_NUM; i++) {
                if (nf_ct_cache[i].use == 0)
                        continue;
@@ -1259,6 +1260,7 @@ int __init nf_conntrack_init(void)
 
        /* For use by REJECT target */
        rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach);
+       rcu_assign_pointer(nf_ct_destroy, destroy_conntrack);
 
        /* Set up fake conntrack:
            - to never be deleted, not in any hashes */