aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>2007-07-08 01:26:16 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-11 01:17:36 -0400
commitd8a0509a696de60296a66ba4fe4f9eaade497103 (patch)
tree6aa00195176f8cd05221e356877ec83d0aa0536c /net/ipv4
parentdacd2a1a5cf621288833aa3c6e815b86a1536538 (diff)
[NETFILTER]: nf_nat: kill global 'destroy' operation
This kills the global 'destroy' operation which was used by NAT. Instead it uses the extension infrastructure so that multiple extensions can register own operations. 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>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index 4ce82d7014ff..e370d1568001 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -87,20 +87,6 @@ hash_by_src(const struct nf_conntrack_tuple *tuple)
87 tuple->dst.protonum, 0) % nf_nat_htable_size; 87 tuple->dst.protonum, 0) % nf_nat_htable_size;
88} 88}
89 89
90/* Noone using conntrack by the time this called. */
91static void nf_nat_cleanup_conntrack(struct nf_conn *conn)
92{
93 struct nf_conn_nat *nat;
94 if (!(conn->status & IPS_NAT_DONE_MASK))
95 return;
96
97 nat = nfct_nat(conn);
98 write_lock_bh(&nf_nat_lock);
99 list_del(&nat->info.bysource);
100 nat->info.ct = NULL;
101 write_unlock_bh(&nf_nat_lock);
102}
103
104/* Is this tuple already taken? (not by us) */ 90/* Is this tuple already taken? (not by us) */
105int 91int
106nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, 92nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
@@ -604,6 +590,22 @@ nf_nat_port_nfattr_to_range(struct nfattr *tb[], struct nf_nat_range *range)
604EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nfattr); 590EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nfattr);
605#endif 591#endif
606 592
593/* Noone using conntrack by the time this called. */
594static void nf_nat_cleanup_conntrack(struct nf_conn *ct)
595{
596 struct nf_conn_nat *nat = nf_ct_ext_find(ct, NF_CT_EXT_NAT);
597
598 if (nat == NULL || nat->info.ct == NULL)
599 return;
600
601 NF_CT_ASSERT(nat->info.ct->status & IPS_NAT_DONE_MASK);
602
603 write_lock_bh(&nf_nat_lock);
604 list_del(&nat->info.bysource);
605 nat->info.ct = NULL;
606 write_unlock_bh(&nf_nat_lock);
607}
608
607static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) 609static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
608{ 610{
609 struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT); 611 struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT);
@@ -623,11 +625,12 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
623} 625}
624 626
625struct nf_ct_ext_type nat_extend = { 627struct nf_ct_ext_type nat_extend = {
626 .len = sizeof(struct nf_conn_nat), 628 .len = sizeof(struct nf_conn_nat),
627 .align = __alignof__(struct nf_conn_nat), 629 .align = __alignof__(struct nf_conn_nat),
628 .move = nf_nat_move_storage, 630 .destroy = nf_nat_cleanup_conntrack,
629 .id = NF_CT_EXT_NAT, 631 .move = nf_nat_move_storage,
630 .flags = NF_CT_EXT_F_PREALLOC, 632 .id = NF_CT_EXT_NAT,
633 .flags = NF_CT_EXT_F_PREALLOC,
631}; 634};
632 635
633static int __init nf_nat_init(void) 636static int __init nf_nat_init(void)
@@ -664,10 +667,6 @@ static int __init nf_nat_init(void)
664 INIT_LIST_HEAD(&bysource[i]); 667 INIT_LIST_HEAD(&bysource[i]);
665 } 668 }
666 669
667 /* FIXME: Man, this is a hack. <SIGH> */
668 NF_CT_ASSERT(rcu_dereference(nf_conntrack_destroyed) == NULL);
669 rcu_assign_pointer(nf_conntrack_destroyed, nf_nat_cleanup_conntrack);
670
671 /* Initialize fake conntrack so that NAT will skip it */ 670 /* Initialize fake conntrack so that NAT will skip it */
672 nf_conntrack_untracked.status |= IPS_NAT_DONE_MASK; 671 nf_conntrack_untracked.status |= IPS_NAT_DONE_MASK;
673 672
@@ -694,7 +693,6 @@ static int clean_nat(struct nf_conn *i, void *data)
694static void __exit nf_nat_cleanup(void) 693static void __exit nf_nat_cleanup(void)
695{ 694{
696 nf_ct_iterate_cleanup(&clean_nat, NULL); 695 nf_ct_iterate_cleanup(&clean_nat, NULL);
697 rcu_assign_pointer(nf_conntrack_destroyed, NULL);
698 synchronize_rcu(); 696 synchronize_rcu();
699 vfree(bysource); 697 vfree(bysource);
700 nf_ct_l3proto_put(l3proto); 698 nf_ct_l3proto_put(l3proto);