btrfs: clear __GFP_FS flag in the space cache inode
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / ipv6 / sysctl_net_ipv6.c
blob7cb65ef79f9cd722e270b5d711d170035e7df4c7
1 /*
2 * sysctl_net_ipv6.c: sysctl interface to net IPV6 subsystem.
4 * Changes:
5 * YOSHIFUJI Hideaki @USAGI: added icmp sysctl table.
6 */
8 #include <linux/mm.h>
9 #include <linux/sysctl.h>
10 #include <linux/in6.h>
11 #include <linux/ipv6.h>
12 #include <linux/slab.h>
13 #include <net/ndisc.h>
14 #include <net/ipv6.h>
15 #include <net/addrconf.h>
16 #include <net/inet_frag.h>
18 static struct ctl_table empty[1];
20 static ctl_table ipv6_table_template[] = {
22 .procname = "route",
23 .maxlen = 0,
24 .mode = 0555,
25 .child = ipv6_route_table_template
28 .procname = "icmp",
29 .maxlen = 0,
30 .mode = 0555,
31 .child = ipv6_icmp_table_template
34 .procname = "bindv6only",
35 .data = &init_net.ipv6.sysctl.bindv6only,
36 .maxlen = sizeof(int),
37 .mode = 0644,
38 .proc_handler = proc_dointvec
41 .procname = "neigh",
42 .maxlen = 0,
43 .mode = 0555,
44 .child = empty,
46 { }
49 static ctl_table ipv6_rotable[] = {
51 .procname = "mld_max_msf",
52 .data = &sysctl_mld_max_msf,
53 .maxlen = sizeof(int),
54 .mode = 0644,
55 .proc_handler = proc_dointvec
57 { }
60 struct ctl_path net_ipv6_ctl_path[] = {
61 { .procname = "net", },
62 { .procname = "ipv6", },
63 { },
65 EXPORT_SYMBOL_GPL(net_ipv6_ctl_path);
67 static int __net_init ipv6_sysctl_net_init(struct net *net)
69 struct ctl_table *ipv6_table;
70 struct ctl_table *ipv6_route_table;
71 struct ctl_table *ipv6_icmp_table;
72 int err;
74 err = -ENOMEM;
75 ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
76 GFP_KERNEL);
77 if (!ipv6_table)
78 goto out;
80 ipv6_route_table = ipv6_route_sysctl_init(net);
81 if (!ipv6_route_table)
82 goto out_ipv6_table;
83 ipv6_table[0].child = ipv6_route_table;
85 ipv6_icmp_table = ipv6_icmp_sysctl_init(net);
86 if (!ipv6_icmp_table)
87 goto out_ipv6_route_table;
88 ipv6_table[1].child = ipv6_icmp_table;
90 ipv6_table[2].data = &net->ipv6.sysctl.bindv6only;
92 net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path,
93 ipv6_table);
94 if (!net->ipv6.sysctl.table)
95 goto out_ipv6_icmp_table;
97 err = 0;
98 out:
99 return err;
101 out_ipv6_icmp_table:
102 kfree(ipv6_icmp_table);
103 out_ipv6_route_table:
104 kfree(ipv6_route_table);
105 out_ipv6_table:
106 kfree(ipv6_table);
107 goto out;
110 static void __net_exit ipv6_sysctl_net_exit(struct net *net)
112 struct ctl_table *ipv6_table;
113 struct ctl_table *ipv6_route_table;
114 struct ctl_table *ipv6_icmp_table;
116 ipv6_table = net->ipv6.sysctl.table->ctl_table_arg;
117 ipv6_route_table = ipv6_table[0].child;
118 ipv6_icmp_table = ipv6_table[1].child;
120 unregister_net_sysctl_table(net->ipv6.sysctl.table);
122 kfree(ipv6_table);
123 kfree(ipv6_route_table);
124 kfree(ipv6_icmp_table);
127 static struct pernet_operations ipv6_sysctl_net_ops = {
128 .init = ipv6_sysctl_net_init,
129 .exit = ipv6_sysctl_net_exit,
132 static struct ctl_table_header *ip6_header;
134 int ipv6_sysctl_register(void)
136 int err = -ENOMEM;
138 ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_rotable);
139 if (ip6_header == NULL)
140 goto out;
142 err = register_pernet_subsys(&ipv6_sysctl_net_ops);
143 if (err)
144 goto err_pernet;
145 out:
146 return err;
148 err_pernet:
149 unregister_net_sysctl_table(ip6_header);
150 goto out;
153 void ipv6_sysctl_unregister(void)
155 unregister_net_sysctl_table(ip6_header);
156 unregister_pernet_subsys(&ipv6_sysctl_net_ops);
159 static struct ctl_table_header *ip6_base;
161 int ipv6_static_sysctl_register(void)
163 ip6_base = register_sysctl_paths(net_ipv6_ctl_path, empty);
164 if (ip6_base == NULL)
165 return -ENOMEM;
166 return 0;
169 void ipv6_static_sysctl_unregister(void)
171 unregister_net_sysctl_table(ip6_base);