hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/ipv6/sysctl_net_ipv6.c
....@@ -21,14 +21,13 @@
2121 #include <net/calipso.h>
2222 #endif
2323
24
-static int zero;
25
-static int one = 1;
24
+static int two = 2;
25
+static int flowlabel_reflect_max = 0x7;
2626 static int auto_flowlabels_min;
2727 static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX;
2828
2929 static int proc_rt6_multipath_hash_policy(struct ctl_table *table, int write,
30
- void __user *buffer, size_t *lenp,
31
- loff_t *ppos)
30
+ void *buffer, size_t *lenp, loff_t *ppos)
3231 {
3332 struct net *net;
3433 int ret;
....@@ -113,7 +112,9 @@
113112 .data = &init_net.ipv6.sysctl.flowlabel_reflect,
114113 .maxlen = sizeof(int),
115114 .mode = 0644,
116
- .proc_handler = proc_dointvec,
115
+ .proc_handler = proc_dointvec_minmax,
116
+ .extra1 = SYSCTL_ZERO,
117
+ .extra2 = &flowlabel_reflect_max,
117118 },
118119 {
119120 .procname = "max_dst_opts_number",
....@@ -149,8 +150,8 @@
149150 .maxlen = sizeof(int),
150151 .mode = 0644,
151152 .proc_handler = proc_rt6_multipath_hash_policy,
152
- .extra1 = &zero,
153
- .extra2 = &one,
153
+ .extra1 = SYSCTL_ZERO,
154
+ .extra2 = &two,
154155 },
155156 {
156157 .procname = "seg6_flowlabel",
....@@ -176,7 +177,7 @@
176177 .maxlen = sizeof(int),
177178 .mode = 0644,
178179 .proc_handler = proc_dointvec_minmax,
179
- .extra1 = &one
180
+ .extra1 = SYSCTL_ONE
180181 },
181182 #ifdef CONFIG_NETLABEL
182183 {
....@@ -202,29 +203,16 @@
202203 struct ctl_table *ipv6_table;
203204 struct ctl_table *ipv6_route_table;
204205 struct ctl_table *ipv6_icmp_table;
205
- int err;
206
+ int err, i;
206207
207208 err = -ENOMEM;
208209 ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
209210 GFP_KERNEL);
210211 if (!ipv6_table)
211212 goto out;
212
- ipv6_table[0].data = &net->ipv6.sysctl.bindv6only;
213
- ipv6_table[1].data = &net->ipv6.sysctl.anycast_src_echo_reply;
214
- ipv6_table[2].data = &net->ipv6.sysctl.flowlabel_consistency;
215
- ipv6_table[3].data = &net->ipv6.sysctl.auto_flowlabels;
216
- ipv6_table[4].data = &net->ipv6.sysctl.fwmark_reflect;
217
- ipv6_table[5].data = &net->ipv6.sysctl.idgen_retries;
218
- ipv6_table[6].data = &net->ipv6.sysctl.idgen_delay;
219
- ipv6_table[7].data = &net->ipv6.sysctl.flowlabel_state_ranges;
220
- ipv6_table[8].data = &net->ipv6.sysctl.ip_nonlocal_bind;
221
- ipv6_table[9].data = &net->ipv6.sysctl.flowlabel_reflect;
222
- ipv6_table[10].data = &net->ipv6.sysctl.max_dst_opts_cnt;
223
- ipv6_table[11].data = &net->ipv6.sysctl.max_hbh_opts_cnt;
224
- ipv6_table[12].data = &net->ipv6.sysctl.max_dst_opts_len;
225
- ipv6_table[13].data = &net->ipv6.sysctl.max_hbh_opts_len;
226
- ipv6_table[14].data = &net->ipv6.sysctl.multipath_hash_policy,
227
- ipv6_table[15].data = &net->ipv6.sysctl.seg6_flowlabel;
213
+ /* Update the variables to point into the current struct net */
214
+ for (i = 0; i < ARRAY_SIZE(ipv6_table_template) - 1; i++)
215
+ ipv6_table[i].data += (void *)net - (void *)&init_net;
228216
229217 ipv6_route_table = ipv6_route_sysctl_init(net);
230218 if (!ipv6_route_table)