nf_ct_destroy for nf_conntrack_destroy callbacks
Subsystems (2)
PATCH 1/1 nf_ct_destroy for nf_conntrack_destroy callbacks
Hello,
I made this patch to allow multiple modules to register for conntrack destroy callback. I was wondering what are your thoughts on this. Thanks
Mohammad
net/ipv4/netfilter/nf_nat_core.c +2 -5
@@ -615,9 +615,7 @@INIT_LIST_HEAD (&bysource[i]); } -/* FIXME: Man, this is a hack. <SIGH> */ -NF_CT_ASSERT (rcu_dereference (nf_conntrack_destroyed) ==NULL ); -rcu_assign_pointer (nf_conntrack_destroyed, nf_nat_cleanup_conntrack); +nf_ct_register_destroy_cb (&nf_nat_cleanup_conntrack);/* Initialize fake conntrack so that NAT will skip it */ nf_conntrack_untracked.status |=IPS_NAT_DONE_MASK ;
@@ -641,8 +639,7 @@ static void __exit nf_nat_cleanup(void) {nf_ct_iterate_cleanup (&clean_nat,NULL ); -rcu_assign_pointer (nf_conntrack_destroyed,NULL ); -synchronize_rcu (); +nf_ct_unregister_destroy_cb (&nf_nat_cleanup_conntrack);vfree (bysource);nf_ct_l3proto_put (l3proto); }
net/netfilter/nf_conntrack_core.c +58 -7
91 lines not on this page · raw message
include/net/netfilter/nf_conntrack.h +2 -1
@@ -224,7 +224,8 @@ int dir);/* Call me when a conntrack is destroyed. */ -extern void (*nf_conntrack_destroyed)(struct nf_conn *conntrack); +extern int nf_ct_register_destroy_cb (void (*destroy)(struct nf_conn *ct)); +extern void nf_ct_unregister_destroy_cb (void (*destroy)(struct nf_conn *ct));/* Fake conntrack entry for untracked connections */ extern struct nf_conn nf_conntrack_untracked;
Hi,
From: "Mohammad Mohsenzadeh" <[email protected]>
Date: Thu, 31 May 2007 10:36:39 -0400
Quoted 4 lines
Hello,
I made this patch to allow multiple modules to register for conntrack destroy callback. I was wondering what are your thoughts on this. Thanks
I have a plan to add it with ct_extend - which allocates extended area in conntrack. Please see archives. By the way,
net/ipv4/netfilter/nf_nat_core.c line 619
Quoted 9 lines
net/ipv4/netfilter/nf_nat_core.c +1
-3@@ -615,9 +615,7 @@INIT_LIST_HEAD (&bysource[i]); } -/* FIXME: Man, this is a hack. <SIGH> */ -NF_CT_ASSERT (rcu_dereference (nf_conntrack_destroyed) ==NULL ); -rcu_assign_pointer (nf_conntrack_destroyed, nf_nat_cleanup_conntrack); +nf_ct_register_destroy_cb (&nf_nat_cleanup_conntrack);
The coding style is not aligned. Or any your tool mangled white spaces ?
Quoted 16 lines
net/netfilter/nf_conntrack_core.c +15
-0int +nf_ct_register_destroy_cb (void (*destroy)(struct nf_conn *ct)) +{ +struct nf_ct_destroy *entry; + +write_lock_bh (&nf_ct_destroy_lock); + list_for_each_entry (entry, &nf_ct_destroy_head, list) { +if (entry->destroy == destroy) { +write_unlock_bh (&nf_ct_destroy_lock); +return -EINVAL ; + } + } + + entry =kmalloc (sizeof (struct nf_ct_destroy ),GFP_ATOMIC ); +if (!entry) { +write_unlock_bh (&nf_ct_destroy_lock);
net/netfilter/nf_conntrack_core.c line 291
Quoted 10 lines
net/netfilter/nf_conntrack_core.c +10
-0+return -ENOMEM ; + } + + entry->destroy = destroy; +list_add (&entry->list, &nf_ct_destroy_head); +write_unlock_bh (&nf_ct_destroy_lock); + +return 0 ; +} +EXPORT_SYMBOL_GPL (nf_ct_register_destroy_cb);
You can replace lock with RCU.
-- Yasuyuki Kozakai