2 * sysctl_net_ipv6.c: sysctl interface to net IPV6 subsystem.
5 * YOSHIFUJI Hideaki @USAGI: added icmp sysctl table.
9 #include <linux/sysctl.h>
10 #include <linux/in6.h>
11 #include <linux/ipv6.h>
12 #include <linux/slab.h>
13 #include <linux/export.h>
14 #include <net/ndisc.h>
16 #include <net/addrconf.h>
17 #include <net/inet_frag.h>
19 static struct ctl_table empty[1];
21 static ctl_table ipv6_static_skeleton[] = {
31 static ctl_table ipv6_table_template[] = {
36 .child = ipv6_route_table_template
42 .child = ipv6_icmp_table_template
45 .procname = "bindv6only",
46 .data = &init_net.ipv6.sysctl.bindv6only,
47 .maxlen = sizeof(int),
49 .proc_handler = proc_dointvec
54 static ctl_table ipv6_rotable[] = {
56 .procname = "mld_max_msf",
57 .data = &sysctl_mld_max_msf,
58 .maxlen = sizeof(int),
60 .proc_handler = proc_dointvec
65 struct ctl_path net_ipv6_ctl_path[] = {
66 { .procname = "net", },
67 { .procname = "ipv6", },
70 EXPORT_SYMBOL_GPL(net_ipv6_ctl_path);
72 static int __net_init ipv6_sysctl_net_init(struct net *net)
74 struct ctl_table *ipv6_table;
75 struct ctl_table *ipv6_route_table;
76 struct ctl_table *ipv6_icmp_table;
80 ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
85 ipv6_route_table = ipv6_route_sysctl_init(net);
86 if (!ipv6_route_table)
88 ipv6_table[0].child = ipv6_route_table;
90 ipv6_icmp_table = ipv6_icmp_sysctl_init(net);
92 goto out_ipv6_route_table;
93 ipv6_table[1].child = ipv6_icmp_table;
95 ipv6_table[2].data = &net->ipv6.sysctl.bindv6only;
97 net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path,
99 if (!net->ipv6.sysctl.table)
100 goto out_ipv6_icmp_table;
107 kfree(ipv6_icmp_table);
108 out_ipv6_route_table:
109 kfree(ipv6_route_table);
115 static void __net_exit ipv6_sysctl_net_exit(struct net *net)
117 struct ctl_table *ipv6_table;
118 struct ctl_table *ipv6_route_table;
119 struct ctl_table *ipv6_icmp_table;
121 ipv6_table = net->ipv6.sysctl.table->ctl_table_arg;
122 ipv6_route_table = ipv6_table[0].child;
123 ipv6_icmp_table = ipv6_table[1].child;
125 unregister_net_sysctl_table(net->ipv6.sysctl.table);
128 kfree(ipv6_route_table);
129 kfree(ipv6_icmp_table);
132 static struct pernet_operations ipv6_sysctl_net_ops = {
133 .init = ipv6_sysctl_net_init,
134 .exit = ipv6_sysctl_net_exit,
137 static struct ctl_table_header *ip6_header;
139 int ipv6_sysctl_register(void)
143 ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_rotable);
144 if (ip6_header == NULL)
147 err = register_pernet_subsys(&ipv6_sysctl_net_ops);
154 unregister_net_sysctl_table(ip6_header);
158 void ipv6_sysctl_unregister(void)
160 unregister_net_sysctl_table(ip6_header);
161 unregister_pernet_subsys(&ipv6_sysctl_net_ops);
164 static struct ctl_table_header *ip6_base;
166 int ipv6_static_sysctl_register(void)
168 ip6_base = register_sysctl_paths(net_ipv6_ctl_path, ipv6_static_skeleton);
169 if (ip6_base == NULL)
174 void ipv6_static_sysctl_unregister(void)
176 unregister_net_sysctl_table(ip6_base);