Linux 2.6.33.13
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / ipv6 / sysctl_net_ipv6.c
blobc690736885b4695f9e96f8b1991d01684fbeebcf
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 <net/ndisc.h>
13 #include <net/ipv6.h>
14 #include <net/addrconf.h>
15 #include <net/inet_frag.h>
17 static ctl_table ipv6_table_template[] = {
19 .procname = "route",
20 .maxlen = 0,
21 .mode = 0555,
22 .child = ipv6_route_table_template
25 .procname = "icmp",
26 .maxlen = 0,
27 .mode = 0555,
28 .child = ipv6_icmp_table_template
31 .procname = "bindv6only",
32 .data = &init_net.ipv6.sysctl.bindv6only,
33 .maxlen = sizeof(int),
34 .mode = 0644,
35 .proc_handler = proc_dointvec
37 { }
40 static ctl_table ipv6_rotable[] = {
42 .procname = "mld_max_msf",
43 .data = &sysctl_mld_max_msf,
44 .maxlen = sizeof(int),
45 .mode = 0644,
46 .proc_handler = proc_dointvec
48 { }
51 struct ctl_path net_ipv6_ctl_path[] = {
52 { .procname = "net", },
53 { .procname = "ipv6", },
54 { },
56 EXPORT_SYMBOL_GPL(net_ipv6_ctl_path);
58 static int ipv6_sysctl_net_init(struct net *net)
60 struct ctl_table *ipv6_table;
61 struct ctl_table *ipv6_route_table;
62 struct ctl_table *ipv6_icmp_table;
63 int err;
65 err = -ENOMEM;
66 ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
67 GFP_KERNEL);
68 if (!ipv6_table)
69 goto out;
71 ipv6_route_table = ipv6_route_sysctl_init(net);
72 if (!ipv6_route_table)
73 goto out_ipv6_table;
74 ipv6_table[0].child = ipv6_route_table;
76 ipv6_icmp_table = ipv6_icmp_sysctl_init(net);
77 if (!ipv6_icmp_table)
78 goto out_ipv6_route_table;
79 ipv6_table[1].child = ipv6_icmp_table;
81 ipv6_table[2].data = &net->ipv6.sysctl.bindv6only;
83 net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path,
84 ipv6_table);
85 if (!net->ipv6.sysctl.table)
86 goto out_ipv6_icmp_table;
88 err = 0;
89 out:
90 return err;
92 out_ipv6_icmp_table:
93 kfree(ipv6_icmp_table);
94 out_ipv6_route_table:
95 kfree(ipv6_route_table);
96 out_ipv6_table:
97 kfree(ipv6_table);
98 goto out;
101 static void ipv6_sysctl_net_exit(struct net *net)
103 struct ctl_table *ipv6_table;
104 struct ctl_table *ipv6_route_table;
105 struct ctl_table *ipv6_icmp_table;
107 ipv6_table = net->ipv6.sysctl.table->ctl_table_arg;
108 ipv6_route_table = ipv6_table[0].child;
109 ipv6_icmp_table = ipv6_table[1].child;
111 unregister_net_sysctl_table(net->ipv6.sysctl.table);
113 kfree(ipv6_table);
114 kfree(ipv6_route_table);
115 kfree(ipv6_icmp_table);
118 static struct pernet_operations ipv6_sysctl_net_ops = {
119 .init = ipv6_sysctl_net_init,
120 .exit = ipv6_sysctl_net_exit,
123 static struct ctl_table_header *ip6_header;
125 int ipv6_sysctl_register(void)
127 int err = -ENOMEM;
129 ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_rotable);
130 if (ip6_header == NULL)
131 goto out;
133 err = register_pernet_subsys(&ipv6_sysctl_net_ops);
134 if (err)
135 goto err_pernet;
136 out:
137 return err;
139 err_pernet:
140 unregister_net_sysctl_table(ip6_header);
141 goto out;
144 void ipv6_sysctl_unregister(void)
146 unregister_net_sysctl_table(ip6_header);
147 unregister_pernet_subsys(&ipv6_sysctl_net_ops);
150 static struct ctl_table_header *ip6_base;
152 int ipv6_static_sysctl_register(void)
154 static struct ctl_table empty[1];
155 ip6_base = register_sysctl_paths(net_ipv6_ctl_path, empty);
156 if (ip6_base == NULL)
157 return -ENOMEM;
158 return 0;
161 void ipv6_static_sysctl_unregister(void)
163 unregister_net_sysctl_table(ip6_base);