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 <net/ndisc.h>
14 #include <net/addrconf.h>
15 #include <net/inet_frag.h>
17 static ctl_table ipv6_table_template
[] = {
22 .child
= ipv6_route_table_template
28 .child
= ipv6_icmp_table_template
31 .procname
= "bindv6only",
32 .data
= &init_net
.ipv6
.sysctl
.bindv6only
,
33 .maxlen
= sizeof(int),
35 .proc_handler
= proc_dointvec
40 static ctl_table ipv6_rotable
[] = {
42 .procname
= "mld_max_msf",
43 .data
= &sysctl_mld_max_msf
,
44 .maxlen
= sizeof(int),
46 .proc_handler
= proc_dointvec
51 struct ctl_path net_ipv6_ctl_path
[] = {
52 { .procname
= "net", },
53 { .procname
= "ipv6", },
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
;
66 ipv6_table
= kmemdup(ipv6_table_template
, sizeof(ipv6_table_template
),
71 ipv6_route_table
= ipv6_route_sysctl_init(net
);
72 if (!ipv6_route_table
)
74 ipv6_table
[0].child
= ipv6_route_table
;
76 ipv6_icmp_table
= ipv6_icmp_sysctl_init(net
);
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
,
85 if (!net
->ipv6
.sysctl
.table
)
86 goto out_ipv6_icmp_table
;
93 kfree(ipv6_icmp_table
);
95 kfree(ipv6_route_table
);
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
);
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)
129 ip6_header
= register_net_sysctl_rotable(net_ipv6_ctl_path
, ipv6_rotable
);
130 if (ip6_header
== NULL
)
133 err
= register_pernet_subsys(&ipv6_sysctl_net_ops
);
140 unregister_net_sysctl_table(ip6_header
);
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
)
161 void ipv6_static_sysctl_unregister(void)
163 unregister_net_sysctl_table(ip6_base
);