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>
21 static struct ctl_table ipv6_table_template
[] = {
23 .procname
= "bindv6only",
24 .data
= &init_net
.ipv6
.sysctl
.bindv6only
,
25 .maxlen
= sizeof(int),
27 .proc_handler
= proc_dointvec
30 .procname
= "anycast_src_echo_reply",
31 .data
= &init_net
.ipv6
.sysctl
.anycast_src_echo_reply
,
32 .maxlen
= sizeof(int),
34 .proc_handler
= proc_dointvec
37 .procname
= "flowlabel_consistency",
38 .data
= &init_net
.ipv6
.sysctl
.flowlabel_consistency
,
39 .maxlen
= sizeof(int),
41 .proc_handler
= proc_dointvec
44 .procname
= "auto_flowlabels",
45 .data
= &init_net
.ipv6
.sysctl
.auto_flowlabels
,
46 .maxlen
= sizeof(int),
48 .proc_handler
= proc_dointvec
51 .procname
= "fwmark_reflect",
52 .data
= &init_net
.ipv6
.sysctl
.fwmark_reflect
,
53 .maxlen
= sizeof(int),
55 .proc_handler
= proc_dointvec
58 .procname
= "idgen_retries",
59 .data
= &init_net
.ipv6
.sysctl
.idgen_retries
,
60 .maxlen
= sizeof(int),
62 .proc_handler
= proc_dointvec
,
65 .procname
= "idgen_delay",
66 .data
= &init_net
.ipv6
.sysctl
.idgen_delay
,
67 .maxlen
= sizeof(int),
69 .proc_handler
= proc_dointvec_jiffies
,
74 static struct ctl_table ipv6_rotable
[] = {
76 .procname
= "mld_max_msf",
77 .data
= &sysctl_mld_max_msf
,
78 .maxlen
= sizeof(int),
80 .proc_handler
= proc_dointvec
83 .procname
= "mld_qrv",
84 .data
= &sysctl_mld_qrv
,
85 .maxlen
= sizeof(int),
87 .proc_handler
= proc_dointvec_minmax
,
93 static int __net_init
ipv6_sysctl_net_init(struct net
*net
)
95 struct ctl_table
*ipv6_table
;
96 struct ctl_table
*ipv6_route_table
;
97 struct ctl_table
*ipv6_icmp_table
;
101 ipv6_table
= kmemdup(ipv6_table_template
, sizeof(ipv6_table_template
),
105 ipv6_table
[0].data
= &net
->ipv6
.sysctl
.bindv6only
;
106 ipv6_table
[1].data
= &net
->ipv6
.sysctl
.anycast_src_echo_reply
;
107 ipv6_table
[2].data
= &net
->ipv6
.sysctl
.flowlabel_consistency
;
108 ipv6_table
[3].data
= &net
->ipv6
.sysctl
.auto_flowlabels
;
109 ipv6_table
[4].data
= &net
->ipv6
.sysctl
.fwmark_reflect
;
110 ipv6_table
[5].data
= &net
->ipv6
.sysctl
.idgen_retries
;
111 ipv6_table
[6].data
= &net
->ipv6
.sysctl
.idgen_delay
;
113 ipv6_route_table
= ipv6_route_sysctl_init(net
);
114 if (!ipv6_route_table
)
117 ipv6_icmp_table
= ipv6_icmp_sysctl_init(net
);
118 if (!ipv6_icmp_table
)
119 goto out_ipv6_route_table
;
121 net
->ipv6
.sysctl
.hdr
= register_net_sysctl(net
, "net/ipv6", ipv6_table
);
122 if (!net
->ipv6
.sysctl
.hdr
)
123 goto out_ipv6_icmp_table
;
125 net
->ipv6
.sysctl
.route_hdr
=
126 register_net_sysctl(net
, "net/ipv6/route", ipv6_route_table
);
127 if (!net
->ipv6
.sysctl
.route_hdr
)
128 goto out_unregister_ipv6_table
;
130 net
->ipv6
.sysctl
.icmp_hdr
=
131 register_net_sysctl(net
, "net/ipv6/icmp", ipv6_icmp_table
);
132 if (!net
->ipv6
.sysctl
.icmp_hdr
)
133 goto out_unregister_route_table
;
138 out_unregister_route_table
:
139 unregister_net_sysctl_table(net
->ipv6
.sysctl
.route_hdr
);
140 out_unregister_ipv6_table
:
141 unregister_net_sysctl_table(net
->ipv6
.sysctl
.hdr
);
143 kfree(ipv6_icmp_table
);
144 out_ipv6_route_table
:
145 kfree(ipv6_route_table
);
151 static void __net_exit
ipv6_sysctl_net_exit(struct net
*net
)
153 struct ctl_table
*ipv6_table
;
154 struct ctl_table
*ipv6_route_table
;
155 struct ctl_table
*ipv6_icmp_table
;
157 ipv6_table
= net
->ipv6
.sysctl
.hdr
->ctl_table_arg
;
158 ipv6_route_table
= net
->ipv6
.sysctl
.route_hdr
->ctl_table_arg
;
159 ipv6_icmp_table
= net
->ipv6
.sysctl
.icmp_hdr
->ctl_table_arg
;
161 unregister_net_sysctl_table(net
->ipv6
.sysctl
.icmp_hdr
);
162 unregister_net_sysctl_table(net
->ipv6
.sysctl
.route_hdr
);
163 unregister_net_sysctl_table(net
->ipv6
.sysctl
.hdr
);
166 kfree(ipv6_route_table
);
167 kfree(ipv6_icmp_table
);
170 static struct pernet_operations ipv6_sysctl_net_ops
= {
171 .init
= ipv6_sysctl_net_init
,
172 .exit
= ipv6_sysctl_net_exit
,
175 static struct ctl_table_header
*ip6_header
;
177 int ipv6_sysctl_register(void)
181 ip6_header
= register_net_sysctl(&init_net
, "net/ipv6", ipv6_rotable
);
185 err
= register_pernet_subsys(&ipv6_sysctl_net_ops
);
192 unregister_net_sysctl_table(ip6_header
);
196 void ipv6_sysctl_unregister(void)
198 unregister_net_sysctl_table(ip6_header
);
199 unregister_pernet_subsys(&ipv6_sysctl_net_ops
);