Blame view
net/ipv6/sysctl_net_ipv6.c
6.08 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 9 10 |
/* * sysctl_net_ipv6.c: sysctl interface to net IPV6 subsystem. * * Changes: * YOSHIFUJI Hideaki @USAGI: added icmp sysctl table. */ #include <linux/mm.h> #include <linux/sysctl.h> |
1da177e4c Linux-2.6.12-rc2 |
11 12 |
#include <linux/in6.h> #include <linux/ipv6.h> |
5a0e3ad6a include cleanup: ... |
13 |
#include <linux/slab.h> |
bc3b2d7fb net: Add export.h... |
14 |
#include <linux/export.h> |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 |
#include <net/ndisc.h> #include <net/ipv6.h> #include <net/addrconf.h> |
04128f233 [INET]: Collect c... |
18 |
#include <net/inet_frag.h> |
4fee5242b calipso: Add a la... |
19 20 21 |
#ifdef CONFIG_NETLABEL #include <net/calipso.h> #endif |
1da177e4c Linux-2.6.12-rc2 |
22 |
|
2f711939d ipv6: add sysctl_... |
23 |
static int one = 1; |
42240901f ipv6: Implement d... |
24 25 |
static int auto_flowlabels_min; static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX; |
2f711939d ipv6: add sysctl_... |
26 |
|
fe2c6338f net: Convert uses... |
27 |
static struct ctl_table ipv6_table_template[] = { |
1da177e4c Linux-2.6.12-rc2 |
28 |
{ |
1da177e4c Linux-2.6.12-rc2 |
29 |
.procname = "bindv6only", |
99bc9c4e4 [NETNS][IPV6]: Ma... |
30 |
.data = &init_net.ipv6.sysctl.bindv6only, |
1da177e4c Linux-2.6.12-rc2 |
31 32 |
.maxlen = sizeof(int), .mode = 0644, |
6d9f239a1 net: '&' redux |
33 |
.proc_handler = proc_dointvec |
1da177e4c Linux-2.6.12-rc2 |
34 |
}, |
509aba3b0 IPv6: add the opt... |
35 36 |
{ .procname = "anycast_src_echo_reply", |
ec35b61ea IPv6: move the an... |
37 |
.data = &init_net.ipv6.sysctl.anycast_src_echo_reply, |
509aba3b0 IPv6: add the opt... |
38 39 40 41 |
.maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, |
6444f72b4 ipv6: add flowlab... |
42 43 44 45 46 47 48 |
{ .procname = "flowlabel_consistency", .data = &init_net.ipv6.sysctl.flowlabel_consistency, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, |
e110861f8 net: add a sysctl... |
49 |
{ |
cb1ce2ef3 ipv6: Implement a... |
50 51 52 53 |
.procname = "auto_flowlabels", .data = &init_net.ipv6.sysctl.auto_flowlabels, .maxlen = sizeof(int), .mode = 0644, |
42240901f ipv6: Implement d... |
54 55 56 |
.proc_handler = proc_dointvec_minmax, .extra1 = &auto_flowlabels_min, .extra2 = &auto_flowlabels_max |
cb1ce2ef3 ipv6: Implement a... |
57 58 |
}, { |
e110861f8 net: add a sysctl... |
59 60 61 62 63 64 |
.procname = "fwmark_reflect", .data = &init_net.ipv6.sysctl.fwmark_reflect, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, |
1855b7c3e ipv6: introduce i... |
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
{ .procname = "idgen_retries", .data = &init_net.ipv6.sysctl.idgen_retries, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "idgen_delay", .data = &init_net.ipv6.sysctl.idgen_delay, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, |
82a584b7c ipv6: Flow label ... |
79 80 81 82 83 84 85 |
{ .procname = "flowlabel_state_ranges", .data = &init_net.ipv6.sysctl.flowlabel_state_ranges, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, |
35a256fee ipv6: Nonlocal bind |
86 87 88 89 90 91 92 |
{ .procname = "ip_nonlocal_bind", .data = &init_net.ipv6.sysctl.ip_nonlocal_bind, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec }, |
22b6722bf ipv6: Add sysctl ... |
93 94 95 96 97 98 99 |
{ .procname = "flowlabel_reflect", .data = &init_net.ipv6.sysctl.flowlabel_reflect, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, |
f8572d8f2 sysctl net: Remov... |
100 |
{ } |
34ac2573e ipv6: Register so... |
101 |
}; |
fe2c6338f net: Convert uses... |
102 |
static struct ctl_table ipv6_rotable[] = { |
1da177e4c Linux-2.6.12-rc2 |
103 |
{ |
1da177e4c Linux-2.6.12-rc2 |
104 105 106 107 |
.procname = "mld_max_msf", .data = &sysctl_mld_max_msf, .maxlen = sizeof(int), .mode = 0644, |
6d9f239a1 net: '&' redux |
108 |
.proc_handler = proc_dointvec |
1da177e4c Linux-2.6.12-rc2 |
109 |
}, |
2f711939d ipv6: add sysctl_... |
110 111 112 113 114 115 116 117 |
{ .procname = "mld_qrv", .data = &sysctl_mld_qrv, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &one }, |
4fee5242b calipso: Add a la... |
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
#ifdef CONFIG_NETLABEL { .procname = "calipso_cache_enable", .data = &calipso_cache_enabled, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "calipso_cache_bucket_size", .data = &calipso_cache_bucketsize, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, #endif /* CONFIG_NETLABEL */ |
f8572d8f2 sysctl net: Remov... |
134 |
{ } |
1da177e4c Linux-2.6.12-rc2 |
135 |
}; |
2c8c1e729 net: spread __net... |
136 |
static int __net_init ipv6_sysctl_net_init(struct net *net) |
1da177e4c Linux-2.6.12-rc2 |
137 |
{ |
760f2d018 [NETNS][IPV6]: Ma... |
138 139 140 141 142 143 144 145 146 147 |
struct ctl_table *ipv6_table; struct ctl_table *ipv6_route_table; struct ctl_table *ipv6_icmp_table; int err; err = -ENOMEM; ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template), GFP_KERNEL); if (!ipv6_table) goto out; |
6dceb0368 net ipv6: Don't u... |
148 |
ipv6_table[0].data = &net->ipv6.sysctl.bindv6only; |
ec35b61ea IPv6: move the an... |
149 |
ipv6_table[1].data = &net->ipv6.sysctl.anycast_src_echo_reply; |
6444f72b4 ipv6: add flowlab... |
150 |
ipv6_table[2].data = &net->ipv6.sysctl.flowlabel_consistency; |
cb1ce2ef3 ipv6: Implement a... |
151 |
ipv6_table[3].data = &net->ipv6.sysctl.auto_flowlabels; |
d247b6ab3 Merge git://git.k... |
152 |
ipv6_table[4].data = &net->ipv6.sysctl.fwmark_reflect; |
1855b7c3e ipv6: introduce i... |
153 154 |
ipv6_table[5].data = &net->ipv6.sysctl.idgen_retries; ipv6_table[6].data = &net->ipv6.sysctl.idgen_delay; |
82a584b7c ipv6: Flow label ... |
155 |
ipv6_table[7].data = &net->ipv6.sysctl.flowlabel_state_ranges; |
35a256fee ipv6: Nonlocal bind |
156 |
ipv6_table[8].data = &net->ipv6.sysctl.ip_nonlocal_bind; |
22b6722bf ipv6: Add sysctl ... |
157 |
ipv6_table[9].data = &net->ipv6.sysctl.flowlabel_reflect; |
760f2d018 [NETNS][IPV6]: Ma... |
158 159 160 161 162 163 164 165 |
ipv6_route_table = ipv6_route_sysctl_init(net); if (!ipv6_route_table) goto out_ipv6_table; ipv6_icmp_table = ipv6_icmp_sysctl_init(net); if (!ipv6_icmp_table) goto out_ipv6_route_table; |
760f2d018 [NETNS][IPV6]: Ma... |
166 |
|
6dceb0368 net ipv6: Don't u... |
167 168 |
net->ipv6.sysctl.hdr = register_net_sysctl(net, "net/ipv6", ipv6_table); if (!net->ipv6.sysctl.hdr) |
760f2d018 [NETNS][IPV6]: Ma... |
169 |
goto out_ipv6_icmp_table; |
6dceb0368 net ipv6: Don't u... |
170 171 172 173 174 175 176 177 178 |
net->ipv6.sysctl.route_hdr = register_net_sysctl(net, "net/ipv6/route", ipv6_route_table); if (!net->ipv6.sysctl.route_hdr) goto out_unregister_ipv6_table; net->ipv6.sysctl.icmp_hdr = register_net_sysctl(net, "net/ipv6/icmp", ipv6_icmp_table); if (!net->ipv6.sysctl.icmp_hdr) goto out_unregister_route_table; |
760f2d018 [NETNS][IPV6]: Ma... |
179 180 181 |
err = 0; out: return err; |
6dceb0368 net ipv6: Don't u... |
182 183 184 185 |
out_unregister_route_table: unregister_net_sysctl_table(net->ipv6.sysctl.route_hdr); out_unregister_ipv6_table: unregister_net_sysctl_table(net->ipv6.sysctl.hdr); |
760f2d018 [NETNS][IPV6]: Ma... |
186 187 188 189 190 191 192 |
out_ipv6_icmp_table: kfree(ipv6_icmp_table); out_ipv6_route_table: kfree(ipv6_route_table); out_ipv6_table: kfree(ipv6_table); goto out; |
1da177e4c Linux-2.6.12-rc2 |
193 |
} |
2c8c1e729 net: spread __net... |
194 |
static void __net_exit ipv6_sysctl_net_exit(struct net *net) |
89918fc27 [NETNS][IPV6]: Ma... |
195 |
{ |
760f2d018 [NETNS][IPV6]: Ma... |
196 197 198 |
struct ctl_table *ipv6_table; struct ctl_table *ipv6_route_table; struct ctl_table *ipv6_icmp_table; |
6dceb0368 net ipv6: Don't u... |
199 200 201 |
ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg; ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg; ipv6_icmp_table = net->ipv6.sysctl.icmp_hdr->ctl_table_arg; |
760f2d018 [NETNS][IPV6]: Ma... |
202 |
|
6dceb0368 net ipv6: Don't u... |
203 204 205 |
unregister_net_sysctl_table(net->ipv6.sysctl.icmp_hdr); unregister_net_sysctl_table(net->ipv6.sysctl.route_hdr); unregister_net_sysctl_table(net->ipv6.sysctl.hdr); |
760f2d018 [NETNS][IPV6]: Ma... |
206 207 208 209 |
kfree(ipv6_table); kfree(ipv6_route_table); kfree(ipv6_icmp_table); |
89918fc27 [NETNS][IPV6]: Ma... |
210 211 212 213 214 215 |
} static struct pernet_operations ipv6_sysctl_net_ops = { .init = ipv6_sysctl_net_init, .exit = ipv6_sysctl_net_exit, }; |
34ac2573e ipv6: Register so... |
216 |
static struct ctl_table_header *ip6_header; |
89918fc27 [NETNS][IPV6]: Ma... |
217 218 |
int ipv6_sysctl_register(void) { |
c19a28e11 remove lots of do... |
219 |
int err = -ENOMEM; |
34ac2573e ipv6: Register so... |
220 |
|
434447579 net: Kill registe... |
221 |
ip6_header = register_net_sysctl(&init_net, "net/ipv6", ipv6_rotable); |
63159f29b ipv6: coding styl... |
222 |
if (!ip6_header) |
34ac2573e ipv6: Register so... |
223 224 225 226 227 228 229 230 231 232 233 |
goto out; err = register_pernet_subsys(&ipv6_sysctl_net_ops); if (err) goto err_pernet; out: return err; err_pernet: unregister_net_sysctl_table(ip6_header); goto out; |
89918fc27 [NETNS][IPV6]: Ma... |
234 |
} |
1da177e4c Linux-2.6.12-rc2 |
235 236 |
void ipv6_sysctl_unregister(void) { |
34ac2573e ipv6: Register so... |
237 |
unregister_net_sysctl_table(ip6_header); |
89918fc27 [NETNS][IPV6]: Ma... |
238 |
unregister_pernet_subsys(&ipv6_sysctl_net_ops); |
1da177e4c Linux-2.6.12-rc2 |
239 |
} |