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 <net/ndisc.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[] = {
25 .child = ipv6_route_table_template
31 .child = ipv6_icmp_table_template
34 .procname = "bindv6only",
35 .data = &init_net.ipv6.sysctl.bindv6only,
36 .maxlen = sizeof(int),
38 .proc_handler = proc_dointvec
49 static ctl_table ipv6_rotable[] = {
51 .procname = "mld_max_msf",
52 .data = &sysctl_mld_max_msf,
53 .maxlen = sizeof(int),
55 .proc_handler = proc_dointvec
60 struct ctl_path net_ipv6_ctl_path[] = {
61 { .procname = "net", },
62 { .procname = "ipv6", },
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;
75 ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
80 ipv6_route_table = ipv6_route_sysctl_init(net);
81 if (!ipv6_route_table)
83 ipv6_table[0].child = ipv6_route_table;
85 ipv6_icmp_table = ipv6_icmp_sysctl_init(net);
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,
94 if (!net->ipv6.sysctl.table)
95 goto out_ipv6_icmp_table;
102 kfree(ipv6_icmp_table);
103 out_ipv6_route_table:
104 kfree(ipv6_route_table);
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);
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)
138 ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_rotable);
139 if (ip6_header == NULL)
142 err = register_pernet_subsys(&ipv6_sysctl_net_ops);
149 unregister_net_sysctl_table(ip6_header);
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)
169 void ipv6_static_sysctl_unregister(void)
171 unregister_net_sysctl_table(ip6_base);