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
[] = {
19 .ctl_name
= NET_IPV6_ROUTE
,
23 .child
= ipv6_route_table_template
26 .ctl_name
= NET_IPV6_ICMP
,
30 .child
= ipv6_icmp_table_template
33 .ctl_name
= NET_IPV6_BINDV6ONLY
,
34 .procname
= "bindv6only",
35 .data
= &init_net
.ipv6
.sysctl
.bindv6only
,
36 .maxlen
= sizeof(int),
38 .proc_handler
= &proc_dointvec
43 static ctl_table ipv6_table
[] = {
45 .ctl_name
= NET_IPV6_MLD_MAX_MSF
,
46 .procname
= "mld_max_msf",
47 .data
= &sysctl_mld_max_msf
,
48 .maxlen
= sizeof(int),
50 .proc_handler
= &proc_dointvec
55 struct ctl_path net_ipv6_ctl_path
[] = {
56 { .procname
= "net", .ctl_name
= CTL_NET
, },
57 { .procname
= "ipv6", .ctl_name
= NET_IPV6
, },
60 EXPORT_SYMBOL_GPL(net_ipv6_ctl_path
);
62 static int ipv6_sysctl_net_init(struct net
*net
)
64 struct ctl_table
*ipv6_table
;
65 struct ctl_table
*ipv6_route_table
;
66 struct ctl_table
*ipv6_icmp_table
;
70 ipv6_table
= kmemdup(ipv6_table_template
, sizeof(ipv6_table_template
),
75 ipv6_route_table
= ipv6_route_sysctl_init(net
);
76 if (!ipv6_route_table
)
78 ipv6_table
[0].child
= ipv6_route_table
;
80 ipv6_icmp_table
= ipv6_icmp_sysctl_init(net
);
82 goto out_ipv6_route_table
;
83 ipv6_table
[1].child
= ipv6_icmp_table
;
85 ipv6_table
[2].data
= &net
->ipv6
.sysctl
.bindv6only
;
87 net
->ipv6
.sysctl
.table
= register_net_sysctl_table(net
, net_ipv6_ctl_path
,
89 if (!net
->ipv6
.sysctl
.table
)
90 goto out_ipv6_icmp_table
;
97 kfree(ipv6_icmp_table
);
99 kfree(ipv6_route_table
);
105 static void ipv6_sysctl_net_exit(struct net
*net
)
107 struct ctl_table
*ipv6_table
;
108 struct ctl_table
*ipv6_route_table
;
109 struct ctl_table
*ipv6_icmp_table
;
111 ipv6_table
= net
->ipv6
.sysctl
.table
->ctl_table_arg
;
112 ipv6_route_table
= ipv6_table
[0].child
;
113 ipv6_icmp_table
= ipv6_table
[1].child
;
115 unregister_net_sysctl_table(net
->ipv6
.sysctl
.table
);
118 kfree(ipv6_route_table
);
119 kfree(ipv6_icmp_table
);
122 static struct pernet_operations ipv6_sysctl_net_ops
= {
123 .init
= ipv6_sysctl_net_init
,
124 .exit
= ipv6_sysctl_net_exit
,
127 static struct ctl_table_header
*ip6_header
;
129 int ipv6_sysctl_register(void)
133 ip6_header
= register_net_sysctl_rotable(net_ipv6_ctl_path
, ipv6_table
);
134 if (ip6_header
== NULL
)
137 err
= register_pernet_subsys(&ipv6_sysctl_net_ops
);
144 unregister_net_sysctl_table(ip6_header
);
148 void ipv6_sysctl_unregister(void)
150 unregister_net_sysctl_table(ip6_header
);
151 unregister_pernet_subsys(&ipv6_sysctl_net_ops
);
154 static struct ctl_table_header
*ip6_base
;
156 int ipv6_static_sysctl_register(void)
158 static struct ctl_table empty
[1];
159 ip6_base
= register_sysctl_paths(net_ipv6_ctl_path
, empty
);
160 if (ip6_base
== NULL
)
165 void ipv6_static_sysctl_unregister(void)
167 unregister_net_sysctl_table(ip6_base
);