aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2008-01-31 07:05:09 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:27:41 -0500
commit9ea0cb2601c4747dff758a9a7a5a4a433ad527f3 (patch)
tree3a8c85473b3f96abf54aefde3d90fd4a3878e609 /net/ipv4
parent79df341ab6c0b1eab77921265ddd1b17ec4db13a (diff)
[NETFILTER]: arp_tables: per-netns arp_tables FILTER
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> 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/arptable_filter.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index 1a688607fe83..4e9c496a30c2 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -20,7 +20,7 @@ static struct
20 struct arpt_replace repl; 20 struct arpt_replace repl;
21 struct arpt_standard entries[3]; 21 struct arpt_standard entries[3];
22 struct arpt_error term; 22 struct arpt_error term;
23} initial_table __initdata = { 23} initial_table __net_initdata = {
24 .repl = { 24 .repl = {
25 .name = "filter", 25 .name = "filter",
26 .valid_hooks = FILTER_VALID_HOOKS, 26 .valid_hooks = FILTER_VALID_HOOKS,
@@ -45,7 +45,7 @@ static struct
45 .term = ARPT_ERROR_INIT, 45 .term = ARPT_ERROR_INIT,
46}; 46};
47 47
48static struct arpt_table __packet_filter = { 48static struct arpt_table packet_filter = {
49 .name = "filter", 49 .name = "filter",
50 .valid_hooks = FILTER_VALID_HOOKS, 50 .valid_hooks = FILTER_VALID_HOOKS,
51 .lock = RW_LOCK_UNLOCKED, 51 .lock = RW_LOCK_UNLOCKED,
@@ -53,7 +53,6 @@ static struct arpt_table __packet_filter = {
53 .me = THIS_MODULE, 53 .me = THIS_MODULE,
54 .af = NF_ARP, 54 .af = NF_ARP,
55}; 55};
56static struct arpt_table *packet_filter;
57 56
58/* The work comes in here from netfilter.c */ 57/* The work comes in here from netfilter.c */
59static unsigned int arpt_hook(unsigned int hook, 58static unsigned int arpt_hook(unsigned int hook,
@@ -62,7 +61,7 @@ static unsigned int arpt_hook(unsigned int hook,
62 const struct net_device *out, 61 const struct net_device *out,
63 int (*okfn)(struct sk_buff *)) 62 int (*okfn)(struct sk_buff *))
64{ 63{
65 return arpt_do_table(skb, hook, in, out, packet_filter); 64 return arpt_do_table(skb, hook, in, out, init_net.ipv4.arptable_filter);
66} 65}
67 66
68static struct nf_hook_ops arpt_ops[] __read_mostly = { 67static struct nf_hook_ops arpt_ops[] __read_mostly = {
@@ -86,14 +85,33 @@ static struct nf_hook_ops arpt_ops[] __read_mostly = {
86 }, 85 },
87}; 86};
88 87
88static int __net_init arptable_filter_net_init(struct net *net)
89{
90 /* Register table */
91 net->ipv4.arptable_filter =
92 arpt_register_table(net, &packet_filter, &initial_table.repl);
93 if (IS_ERR(net->ipv4.arptable_filter))
94 return PTR_ERR(net->ipv4.arptable_filter);
95 return 0;
96}
97
98static void __net_exit arptable_filter_net_exit(struct net *net)
99{
100 arpt_unregister_table(net->ipv4.arptable_filter);
101}
102
103static struct pernet_operations arptable_filter_net_ops = {
104 .init = arptable_filter_net_init,
105 .exit = arptable_filter_net_exit,
106};
107
89static int __init arptable_filter_init(void) 108static int __init arptable_filter_init(void)
90{ 109{
91 int ret; 110 int ret;
92 111
93 /* Register table */ 112 ret = register_pernet_subsys(&arptable_filter_net_ops);
94 packet_filter = arpt_register_table(&init_net, &__packet_filter, &initial_table.repl); 113 if (ret < 0)
95 if (IS_ERR(packet_filter)) 114 return ret;
96 return PTR_ERR(packet_filter);
97 115
98 ret = nf_register_hooks(arpt_ops, ARRAY_SIZE(arpt_ops)); 116 ret = nf_register_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
99 if (ret < 0) 117 if (ret < 0)
@@ -101,14 +119,14 @@ static int __init arptable_filter_init(void)
101 return ret; 119 return ret;
102 120
103cleanup_table: 121cleanup_table:
104 arpt_unregister_table(packet_filter); 122 unregister_pernet_subsys(&arptable_filter_net_ops);
105 return ret; 123 return ret;
106} 124}
107 125
108static void __exit arptable_filter_fini(void) 126static void __exit arptable_filter_fini(void)
109{ 127{
110 nf_unregister_hooks(arpt_ops, ARRAY_SIZE(arpt_ops)); 128 nf_unregister_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
111 arpt_unregister_table(packet_filter); 129 unregister_pernet_subsys(&arptable_filter_net_ops);
112} 130}
113 131
114module_init(arptable_filter_init); 132module_init(arptable_filter_init);