aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2010-01-18 02:25:47 -0500
committerPatrick McHardy <kaber@trash.net>2010-01-18 02:25:47 -0500
commitf54e9367f8499a9bf6b2afbc0dce63e1d53c525a (patch)
treea2e852b0fc05c0e1397136bca29c359163bc2445 /net/ipv4
parenta83d8e8d099fc373a5ca7112ad08c553bb2c180f (diff)
netfilter: xtables: add struct xt_mtdtor_param::net
Add ->net to match destructor list like ->net in constructor list. Make sure it's set in ebtables/iptables/ip6tables, this requires to propagate netns up to *_unregister_table(). Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/ip_tables.c25
-rw-r--r--net/ipv4/netfilter/iptable_filter.c2
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c2
-rw-r--r--net/ipv4/netfilter/iptable_raw.c2
-rw-r--r--net/ipv4/netfilter/iptable_security.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c2
6 files changed, 18 insertions, 17 deletions
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index a069d72d9482..cfaba0e2e6fc 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -553,13 +553,14 @@ mark_source_chains(struct xt_table_info *newinfo,
553} 553}
554 554
555static int 555static int
556cleanup_match(struct ipt_entry_match *m, unsigned int *i) 556cleanup_match(struct ipt_entry_match *m, struct net *net, unsigned int *i)
557{ 557{
558 struct xt_mtdtor_param par; 558 struct xt_mtdtor_param par;
559 559
560 if (i && (*i)-- == 0) 560 if (i && (*i)-- == 0)
561 return 1; 561 return 1;
562 562
563 par.net = net;
563 par.match = m->u.kernel.match; 564 par.match = m->u.kernel.match;
564 par.matchinfo = m->data; 565 par.matchinfo = m->data;
565 par.family = NFPROTO_IPV4; 566 par.family = NFPROTO_IPV4;
@@ -705,7 +706,7 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
705 err: 706 err:
706 module_put(t->u.kernel.target->me); 707 module_put(t->u.kernel.target->me);
707 cleanup_matches: 708 cleanup_matches:
708 IPT_MATCH_ITERATE(e, cleanup_match, &j); 709 IPT_MATCH_ITERATE(e, cleanup_match, net, &j);
709 return ret; 710 return ret;
710} 711}
711 712
@@ -775,7 +776,7 @@ check_entry_size_and_hooks(struct ipt_entry *e,
775} 776}
776 777
777static int 778static int
778cleanup_entry(struct ipt_entry *e, unsigned int *i) 779cleanup_entry(struct ipt_entry *e, struct net *net, unsigned int *i)
779{ 780{
780 struct xt_tgdtor_param par; 781 struct xt_tgdtor_param par;
781 struct ipt_entry_target *t; 782 struct ipt_entry_target *t;
@@ -784,7 +785,7 @@ cleanup_entry(struct ipt_entry *e, unsigned int *i)
784 return 1; 785 return 1;
785 786
786 /* Cleanup all matches */ 787 /* Cleanup all matches */
787 IPT_MATCH_ITERATE(e, cleanup_match, NULL); 788 IPT_MATCH_ITERATE(e, cleanup_match, net, NULL);
788 t = ipt_get_target(e); 789 t = ipt_get_target(e);
789 790
790 par.target = t->u.kernel.target; 791 par.target = t->u.kernel.target;
@@ -866,7 +867,7 @@ translate_table(struct net *net,
866 867
867 if (ret != 0) { 868 if (ret != 0) {
868 IPT_ENTRY_ITERATE(entry0, newinfo->size, 869 IPT_ENTRY_ITERATE(entry0, newinfo->size,
869 cleanup_entry, &i); 870 cleanup_entry, net, &i);
870 return ret; 871 return ret;
871 } 872 }
872 873
@@ -1260,7 +1261,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
1260 /* Decrease module usage counts and free resource */ 1261 /* Decrease module usage counts and free resource */
1261 loc_cpu_old_entry = oldinfo->entries[raw_smp_processor_id()]; 1262 loc_cpu_old_entry = oldinfo->entries[raw_smp_processor_id()];
1262 IPT_ENTRY_ITERATE(loc_cpu_old_entry, oldinfo->size, cleanup_entry, 1263 IPT_ENTRY_ITERATE(loc_cpu_old_entry, oldinfo->size, cleanup_entry,
1263 NULL); 1264 net, NULL);
1264 xt_free_table_info(oldinfo); 1265 xt_free_table_info(oldinfo);
1265 if (copy_to_user(counters_ptr, counters, 1266 if (copy_to_user(counters_ptr, counters,
1266 sizeof(struct xt_counters) * num_counters) != 0) 1267 sizeof(struct xt_counters) * num_counters) != 0)
@@ -1320,7 +1321,7 @@ do_replace(struct net *net, void __user *user, unsigned int len)
1320 return 0; 1321 return 0;
1321 1322
1322 free_newinfo_untrans: 1323 free_newinfo_untrans:
1323 IPT_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry, NULL); 1324 IPT_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry, net, NULL);
1324 free_newinfo: 1325 free_newinfo:
1325 xt_free_table_info(newinfo); 1326 xt_free_table_info(newinfo);
1326 return ret; 1327 return ret;
@@ -1682,7 +1683,7 @@ compat_check_entry(struct ipt_entry *e, struct net *net, const char *name,
1682 return 0; 1683 return 0;
1683 1684
1684 cleanup_matches: 1685 cleanup_matches:
1685 IPT_MATCH_ITERATE(e, cleanup_match, &j); 1686 IPT_MATCH_ITERATE(e, cleanup_match, net, &j);
1686 return ret; 1687 return ret;
1687} 1688}
1688 1689
@@ -1782,7 +1783,7 @@ translate_compat_table(struct net *net,
1782 j -= i; 1783 j -= i;
1783 COMPAT_IPT_ENTRY_ITERATE_CONTINUE(entry0, newinfo->size, i, 1784 COMPAT_IPT_ENTRY_ITERATE_CONTINUE(entry0, newinfo->size, i,
1784 compat_release_entry, &j); 1785 compat_release_entry, &j);
1785 IPT_ENTRY_ITERATE(entry1, newinfo->size, cleanup_entry, &i); 1786 IPT_ENTRY_ITERATE(entry1, newinfo->size, cleanup_entry, net, &i);
1786 xt_free_table_info(newinfo); 1787 xt_free_table_info(newinfo);
1787 return ret; 1788 return ret;
1788 } 1789 }
@@ -1853,7 +1854,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len)
1853 return 0; 1854 return 0;
1854 1855
1855 free_newinfo_untrans: 1856 free_newinfo_untrans:
1856 IPT_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry, NULL); 1857 IPT_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry, net, NULL);
1857 free_newinfo: 1858 free_newinfo:
1858 xt_free_table_info(newinfo); 1859 xt_free_table_info(newinfo);
1859 return ret; 1860 return ret;
@@ -2112,7 +2113,7 @@ out:
2112 return ERR_PTR(ret); 2113 return ERR_PTR(ret);
2113} 2114}
2114 2115
2115void ipt_unregister_table(struct xt_table *table) 2116void ipt_unregister_table(struct net *net, struct xt_table *table)
2116{ 2117{
2117 struct xt_table_info *private; 2118 struct xt_table_info *private;
2118 void *loc_cpu_entry; 2119 void *loc_cpu_entry;
@@ -2122,7 +2123,7 @@ void ipt_unregister_table(struct xt_table *table)
2122 2123
2123 /* Decrease module usage counts and free resources */ 2124 /* Decrease module usage counts and free resources */
2124 loc_cpu_entry = private->entries[raw_smp_processor_id()]; 2125 loc_cpu_entry = private->entries[raw_smp_processor_id()];
2125 IPT_ENTRY_ITERATE(loc_cpu_entry, private->size, cleanup_entry, NULL); 2126 IPT_ENTRY_ITERATE(loc_cpu_entry, private->size, cleanup_entry, net, NULL);
2126 if (private->number > private->initial_entries) 2127 if (private->number > private->initial_entries)
2127 module_put(table_owner); 2128 module_put(table_owner);
2128 xt_free_table_info(private); 2129 xt_free_table_info(private);
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
index df566cbd68e5..dee90eb8aa47 100644
--- a/net/ipv4/netfilter/iptable_filter.c
+++ b/net/ipv4/netfilter/iptable_filter.c
@@ -138,7 +138,7 @@ static int __net_init iptable_filter_net_init(struct net *net)
138 138
139static void __net_exit iptable_filter_net_exit(struct net *net) 139static void __net_exit iptable_filter_net_exit(struct net *net)
140{ 140{
141 ipt_unregister_table(net->ipv4.iptable_filter); 141 ipt_unregister_table(net, net->ipv4.iptable_filter);
142} 142}
143 143
144static struct pernet_operations iptable_filter_net_ops = { 144static struct pernet_operations iptable_filter_net_ops = {
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index fae78c3076c4..e07bf242343a 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -208,7 +208,7 @@ static int __net_init iptable_mangle_net_init(struct net *net)
208 208
209static void __net_exit iptable_mangle_net_exit(struct net *net) 209static void __net_exit iptable_mangle_net_exit(struct net *net)
210{ 210{
211 ipt_unregister_table(net->ipv4.iptable_mangle); 211 ipt_unregister_table(net, net->ipv4.iptable_mangle);
212} 212}
213 213
214static struct pernet_operations iptable_mangle_net_ops = { 214static struct pernet_operations iptable_mangle_net_ops = {
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 993edc23be09..40f2b9f611a2 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -100,7 +100,7 @@ static int __net_init iptable_raw_net_init(struct net *net)
100 100
101static void __net_exit iptable_raw_net_exit(struct net *net) 101static void __net_exit iptable_raw_net_exit(struct net *net)
102{ 102{
103 ipt_unregister_table(net->ipv4.iptable_raw); 103 ipt_unregister_table(net, net->ipv4.iptable_raw);
104} 104}
105 105
106static struct pernet_operations iptable_raw_net_ops = { 106static struct pernet_operations iptable_raw_net_ops = {
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c
index 3bd3d6388da5..7ce2366e4305 100644
--- a/net/ipv4/netfilter/iptable_security.c
+++ b/net/ipv4/netfilter/iptable_security.c
@@ -138,7 +138,7 @@ static int __net_init iptable_security_net_init(struct net *net)
138 138
139static void __net_exit iptable_security_net_exit(struct net *net) 139static void __net_exit iptable_security_net_exit(struct net *net)
140{ 140{
141 ipt_unregister_table(net->ipv4.iptable_security); 141 ipt_unregister_table(net, net->ipv4.iptable_security);
142} 142}
143 143
144static struct pernet_operations iptable_security_net_ops = { 144static struct pernet_operations iptable_security_net_ops = {
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index 9e81e0dfb4ec..85da34fdc755 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -195,7 +195,7 @@ static int __net_init nf_nat_rule_net_init(struct net *net)
195 195
196static void __net_exit nf_nat_rule_net_exit(struct net *net) 196static void __net_exit nf_nat_rule_net_exit(struct net *net)
197{ 197{
198 ipt_unregister_table(net->ipv4.nat_table); 198 ipt_unregister_table(net, net->ipv4.nat_table);
199} 199}
200 200
201static struct pernet_operations nf_nat_rule_net_ops = { 201static struct pernet_operations nf_nat_rule_net_ops = {