aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c90
1 files changed, 9 insertions, 81 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1fd0a3d775d2..f918399c985c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4000,41 +4000,6 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
4000 return ret; 4000 return ret;
4001} 4001}
4002 4002
4003static int addrconf_sysctl_forward_strategy(ctl_table *table,
4004 void __user *oldval,
4005 size_t __user *oldlenp,
4006 void __user *newval, size_t newlen)
4007{
4008 int *valp = table->data;
4009 int val = *valp;
4010 int new;
4011
4012 if (!newval || !newlen)
4013 return 0;
4014 if (newlen != sizeof(int))
4015 return -EINVAL;
4016 if (get_user(new, (int __user *)newval))
4017 return -EFAULT;
4018 if (new == *valp)
4019 return 0;
4020 if (oldval && oldlenp) {
4021 size_t len;
4022 if (get_user(len, oldlenp))
4023 return -EFAULT;
4024 if (len) {
4025 if (len > table->maxlen)
4026 len = table->maxlen;
4027 if (copy_to_user(oldval, valp, len))
4028 return -EFAULT;
4029 if (put_user(len, oldlenp))
4030 return -EFAULT;
4031 }
4032 }
4033
4034 *valp = new;
4035 return addrconf_fixup_forwarding(table, valp, val);
4036}
4037
4038static void dev_disable_change(struct inet6_dev *idev) 4003static void dev_disable_change(struct inet6_dev *idev)
4039{ 4004{
4040 if (!idev || !idev->dev) 4005 if (!idev || !idev->dev)
@@ -4113,16 +4078,13 @@ static struct addrconf_sysctl_table
4113 .sysctl_header = NULL, 4078 .sysctl_header = NULL,
4114 .addrconf_vars = { 4079 .addrconf_vars = {
4115 { 4080 {
4116 .ctl_name = NET_IPV6_FORWARDING,
4117 .procname = "forwarding", 4081 .procname = "forwarding",
4118 .data = &ipv6_devconf.forwarding, 4082 .data = &ipv6_devconf.forwarding,
4119 .maxlen = sizeof(int), 4083 .maxlen = sizeof(int),
4120 .mode = 0644, 4084 .mode = 0644,
4121 .proc_handler = addrconf_sysctl_forward, 4085 .proc_handler = addrconf_sysctl_forward,
4122 .strategy = addrconf_sysctl_forward_strategy,
4123 }, 4086 },
4124 { 4087 {
4125 .ctl_name = NET_IPV6_HOP_LIMIT,
4126 .procname = "hop_limit", 4088 .procname = "hop_limit",
4127 .data = &ipv6_devconf.hop_limit, 4089 .data = &ipv6_devconf.hop_limit,
4128 .maxlen = sizeof(int), 4090 .maxlen = sizeof(int),
@@ -4130,7 +4092,6 @@ static struct addrconf_sysctl_table
4130 .proc_handler = proc_dointvec, 4092 .proc_handler = proc_dointvec,
4131 }, 4093 },
4132 { 4094 {
4133 .ctl_name = NET_IPV6_MTU,
4134 .procname = "mtu", 4095 .procname = "mtu",
4135 .data = &ipv6_devconf.mtu6, 4096 .data = &ipv6_devconf.mtu6,
4136 .maxlen = sizeof(int), 4097 .maxlen = sizeof(int),
@@ -4138,7 +4099,6 @@ static struct addrconf_sysctl_table
4138 .proc_handler = proc_dointvec, 4099 .proc_handler = proc_dointvec,
4139 }, 4100 },
4140 { 4101 {
4141 .ctl_name = NET_IPV6_ACCEPT_RA,
4142 .procname = "accept_ra", 4102 .procname = "accept_ra",
4143 .data = &ipv6_devconf.accept_ra, 4103 .data = &ipv6_devconf.accept_ra,
4144 .maxlen = sizeof(int), 4104 .maxlen = sizeof(int),
@@ -4146,7 +4106,6 @@ static struct addrconf_sysctl_table
4146 .proc_handler = proc_dointvec, 4106 .proc_handler = proc_dointvec,
4147 }, 4107 },
4148 { 4108 {
4149 .ctl_name = NET_IPV6_ACCEPT_REDIRECTS,
4150 .procname = "accept_redirects", 4109 .procname = "accept_redirects",
4151 .data = &ipv6_devconf.accept_redirects, 4110 .data = &ipv6_devconf.accept_redirects,
4152 .maxlen = sizeof(int), 4111 .maxlen = sizeof(int),
@@ -4154,7 +4113,6 @@ static struct addrconf_sysctl_table
4154 .proc_handler = proc_dointvec, 4113 .proc_handler = proc_dointvec,
4155 }, 4114 },
4156 { 4115 {
4157 .ctl_name = NET_IPV6_AUTOCONF,
4158 .procname = "autoconf", 4116 .procname = "autoconf",
4159 .data = &ipv6_devconf.autoconf, 4117 .data = &ipv6_devconf.autoconf,
4160 .maxlen = sizeof(int), 4118 .maxlen = sizeof(int),
@@ -4162,7 +4120,6 @@ static struct addrconf_sysctl_table
4162 .proc_handler = proc_dointvec, 4120 .proc_handler = proc_dointvec,
4163 }, 4121 },
4164 { 4122 {
4165 .ctl_name = NET_IPV6_DAD_TRANSMITS,
4166 .procname = "dad_transmits", 4123 .procname = "dad_transmits",
4167 .data = &ipv6_devconf.dad_transmits, 4124 .data = &ipv6_devconf.dad_transmits,
4168 .maxlen = sizeof(int), 4125 .maxlen = sizeof(int),
@@ -4170,7 +4127,6 @@ static struct addrconf_sysctl_table
4170 .proc_handler = proc_dointvec, 4127 .proc_handler = proc_dointvec,
4171 }, 4128 },
4172 { 4129 {
4173 .ctl_name = NET_IPV6_RTR_SOLICITS,
4174 .procname = "router_solicitations", 4130 .procname = "router_solicitations",
4175 .data = &ipv6_devconf.rtr_solicits, 4131 .data = &ipv6_devconf.rtr_solicits,
4176 .maxlen = sizeof(int), 4132 .maxlen = sizeof(int),
@@ -4178,25 +4134,20 @@ static struct addrconf_sysctl_table
4178 .proc_handler = proc_dointvec, 4134 .proc_handler = proc_dointvec,
4179 }, 4135 },
4180 { 4136 {
4181 .ctl_name = NET_IPV6_RTR_SOLICIT_INTERVAL,
4182 .procname = "router_solicitation_interval", 4137 .procname = "router_solicitation_interval",
4183 .data = &ipv6_devconf.rtr_solicit_interval, 4138 .data = &ipv6_devconf.rtr_solicit_interval,
4184 .maxlen = sizeof(int), 4139 .maxlen = sizeof(int),
4185 .mode = 0644, 4140 .mode = 0644,
4186 .proc_handler = proc_dointvec_jiffies, 4141 .proc_handler = proc_dointvec_jiffies,
4187 .strategy = sysctl_jiffies,
4188 }, 4142 },
4189 { 4143 {
4190 .ctl_name = NET_IPV6_RTR_SOLICIT_DELAY,
4191 .procname = "router_solicitation_delay", 4144 .procname = "router_solicitation_delay",
4192 .data = &ipv6_devconf.rtr_solicit_delay, 4145 .data = &ipv6_devconf.rtr_solicit_delay,
4193 .maxlen = sizeof(int), 4146 .maxlen = sizeof(int),
4194 .mode = 0644, 4147 .mode = 0644,
4195 .proc_handler = proc_dointvec_jiffies, 4148 .proc_handler = proc_dointvec_jiffies,
4196 .strategy = sysctl_jiffies,
4197 }, 4149 },
4198 { 4150 {
4199 .ctl_name = NET_IPV6_FORCE_MLD_VERSION,
4200 .procname = "force_mld_version", 4151 .procname = "force_mld_version",
4201 .data = &ipv6_devconf.force_mld_version, 4152 .data = &ipv6_devconf.force_mld_version,
4202 .maxlen = sizeof(int), 4153 .maxlen = sizeof(int),
@@ -4205,7 +4156,6 @@ static struct addrconf_sysctl_table
4205 }, 4156 },
4206#ifdef CONFIG_IPV6_PRIVACY 4157#ifdef CONFIG_IPV6_PRIVACY
4207 { 4158 {
4208 .ctl_name = NET_IPV6_USE_TEMPADDR,
4209 .procname = "use_tempaddr", 4159 .procname = "use_tempaddr",
4210 .data = &ipv6_devconf.use_tempaddr, 4160 .data = &ipv6_devconf.use_tempaddr,
4211 .maxlen = sizeof(int), 4161 .maxlen = sizeof(int),
@@ -4213,7 +4163,6 @@ static struct addrconf_sysctl_table
4213 .proc_handler = proc_dointvec, 4163 .proc_handler = proc_dointvec,
4214 }, 4164 },
4215 { 4165 {
4216 .ctl_name = NET_IPV6_TEMP_VALID_LFT,
4217 .procname = "temp_valid_lft", 4166 .procname = "temp_valid_lft",
4218 .data = &ipv6_devconf.temp_valid_lft, 4167 .data = &ipv6_devconf.temp_valid_lft,
4219 .maxlen = sizeof(int), 4168 .maxlen = sizeof(int),
@@ -4221,7 +4170,6 @@ static struct addrconf_sysctl_table
4221 .proc_handler = proc_dointvec, 4170 .proc_handler = proc_dointvec,
4222 }, 4171 },
4223 { 4172 {
4224 .ctl_name = NET_IPV6_TEMP_PREFERED_LFT,
4225 .procname = "temp_prefered_lft", 4173 .procname = "temp_prefered_lft",
4226 .data = &ipv6_devconf.temp_prefered_lft, 4174 .data = &ipv6_devconf.temp_prefered_lft,
4227 .maxlen = sizeof(int), 4175 .maxlen = sizeof(int),
@@ -4229,7 +4177,6 @@ static struct addrconf_sysctl_table
4229 .proc_handler = proc_dointvec, 4177 .proc_handler = proc_dointvec,
4230 }, 4178 },
4231 { 4179 {
4232 .ctl_name = NET_IPV6_REGEN_MAX_RETRY,
4233 .procname = "regen_max_retry", 4180 .procname = "regen_max_retry",
4234 .data = &ipv6_devconf.regen_max_retry, 4181 .data = &ipv6_devconf.regen_max_retry,
4235 .maxlen = sizeof(int), 4182 .maxlen = sizeof(int),
@@ -4237,7 +4184,6 @@ static struct addrconf_sysctl_table
4237 .proc_handler = proc_dointvec, 4184 .proc_handler = proc_dointvec,
4238 }, 4185 },
4239 { 4186 {
4240 .ctl_name = NET_IPV6_MAX_DESYNC_FACTOR,
4241 .procname = "max_desync_factor", 4187 .procname = "max_desync_factor",
4242 .data = &ipv6_devconf.max_desync_factor, 4188 .data = &ipv6_devconf.max_desync_factor,
4243 .maxlen = sizeof(int), 4189 .maxlen = sizeof(int),
@@ -4246,7 +4192,6 @@ static struct addrconf_sysctl_table
4246 }, 4192 },
4247#endif 4193#endif
4248 { 4194 {
4249 .ctl_name = NET_IPV6_MAX_ADDRESSES,
4250 .procname = "max_addresses", 4195 .procname = "max_addresses",
4251 .data = &ipv6_devconf.max_addresses, 4196 .data = &ipv6_devconf.max_addresses,
4252 .maxlen = sizeof(int), 4197 .maxlen = sizeof(int),
@@ -4254,7 +4199,6 @@ static struct addrconf_sysctl_table
4254 .proc_handler = proc_dointvec, 4199 .proc_handler = proc_dointvec,
4255 }, 4200 },
4256 { 4201 {
4257 .ctl_name = NET_IPV6_ACCEPT_RA_DEFRTR,
4258 .procname = "accept_ra_defrtr", 4202 .procname = "accept_ra_defrtr",
4259 .data = &ipv6_devconf.accept_ra_defrtr, 4203 .data = &ipv6_devconf.accept_ra_defrtr,
4260 .maxlen = sizeof(int), 4204 .maxlen = sizeof(int),
@@ -4262,7 +4206,6 @@ static struct addrconf_sysctl_table
4262 .proc_handler = proc_dointvec, 4206 .proc_handler = proc_dointvec,
4263 }, 4207 },
4264 { 4208 {
4265 .ctl_name = NET_IPV6_ACCEPT_RA_PINFO,
4266 .procname = "accept_ra_pinfo", 4209 .procname = "accept_ra_pinfo",
4267 .data = &ipv6_devconf.accept_ra_pinfo, 4210 .data = &ipv6_devconf.accept_ra_pinfo,
4268 .maxlen = sizeof(int), 4211 .maxlen = sizeof(int),
@@ -4271,7 +4214,6 @@ static struct addrconf_sysctl_table
4271 }, 4214 },
4272#ifdef CONFIG_IPV6_ROUTER_PREF 4215#ifdef CONFIG_IPV6_ROUTER_PREF
4273 { 4216 {
4274 .ctl_name = NET_IPV6_ACCEPT_RA_RTR_PREF,
4275 .procname = "accept_ra_rtr_pref", 4217 .procname = "accept_ra_rtr_pref",
4276 .data = &ipv6_devconf.accept_ra_rtr_pref, 4218 .data = &ipv6_devconf.accept_ra_rtr_pref,
4277 .maxlen = sizeof(int), 4219 .maxlen = sizeof(int),
@@ -4279,17 +4221,14 @@ static struct addrconf_sysctl_table
4279 .proc_handler = proc_dointvec, 4221 .proc_handler = proc_dointvec,
4280 }, 4222 },
4281 { 4223 {
4282 .ctl_name = NET_IPV6_RTR_PROBE_INTERVAL,
4283 .procname = "router_probe_interval", 4224 .procname = "router_probe_interval",
4284 .data = &ipv6_devconf.rtr_probe_interval, 4225 .data = &ipv6_devconf.rtr_probe_interval,
4285 .maxlen = sizeof(int), 4226 .maxlen = sizeof(int),
4286 .mode = 0644, 4227 .mode = 0644,
4287 .proc_handler = proc_dointvec_jiffies, 4228 .proc_handler = proc_dointvec_jiffies,
4288 .strategy = sysctl_jiffies,
4289 }, 4229 },
4290#ifdef CONFIG_IPV6_ROUTE_INFO 4230#ifdef CONFIG_IPV6_ROUTE_INFO
4291 { 4231 {
4292 .ctl_name = NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN,
4293 .procname = "accept_ra_rt_info_max_plen", 4232 .procname = "accept_ra_rt_info_max_plen",
4294 .data = &ipv6_devconf.accept_ra_rt_info_max_plen, 4233 .data = &ipv6_devconf.accept_ra_rt_info_max_plen,
4295 .maxlen = sizeof(int), 4234 .maxlen = sizeof(int),
@@ -4299,7 +4238,6 @@ static struct addrconf_sysctl_table
4299#endif 4238#endif
4300#endif 4239#endif
4301 { 4240 {
4302 .ctl_name = NET_IPV6_PROXY_NDP,
4303 .procname = "proxy_ndp", 4241 .procname = "proxy_ndp",
4304 .data = &ipv6_devconf.proxy_ndp, 4242 .data = &ipv6_devconf.proxy_ndp,
4305 .maxlen = sizeof(int), 4243 .maxlen = sizeof(int),
@@ -4307,7 +4245,6 @@ static struct addrconf_sysctl_table
4307 .proc_handler = proc_dointvec, 4245 .proc_handler = proc_dointvec,
4308 }, 4246 },
4309 { 4247 {
4310 .ctl_name = NET_IPV6_ACCEPT_SOURCE_ROUTE,
4311 .procname = "accept_source_route", 4248 .procname = "accept_source_route",
4312 .data = &ipv6_devconf.accept_source_route, 4249 .data = &ipv6_devconf.accept_source_route,
4313 .maxlen = sizeof(int), 4250 .maxlen = sizeof(int),
@@ -4316,7 +4253,6 @@ static struct addrconf_sysctl_table
4316 }, 4253 },
4317#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 4254#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
4318 { 4255 {
4319 .ctl_name = CTL_UNNUMBERED,
4320 .procname = "optimistic_dad", 4256 .procname = "optimistic_dad",
4321 .data = &ipv6_devconf.optimistic_dad, 4257 .data = &ipv6_devconf.optimistic_dad,
4322 .maxlen = sizeof(int), 4258 .maxlen = sizeof(int),
@@ -4327,7 +4263,6 @@ static struct addrconf_sysctl_table
4327#endif 4263#endif
4328#ifdef CONFIG_IPV6_MROUTE 4264#ifdef CONFIG_IPV6_MROUTE
4329 { 4265 {
4330 .ctl_name = CTL_UNNUMBERED,
4331 .procname = "mc_forwarding", 4266 .procname = "mc_forwarding",
4332 .data = &ipv6_devconf.mc_forwarding, 4267 .data = &ipv6_devconf.mc_forwarding,
4333 .maxlen = sizeof(int), 4268 .maxlen = sizeof(int),
@@ -4336,16 +4271,13 @@ static struct addrconf_sysctl_table
4336 }, 4271 },
4337#endif 4272#endif
4338 { 4273 {
4339 .ctl_name = CTL_UNNUMBERED,
4340 .procname = "disable_ipv6", 4274 .procname = "disable_ipv6",
4341 .data = &ipv6_devconf.disable_ipv6, 4275 .data = &ipv6_devconf.disable_ipv6,
4342 .maxlen = sizeof(int), 4276 .maxlen = sizeof(int),
4343 .mode = 0644, 4277 .mode = 0644,
4344 .proc_handler = addrconf_sysctl_disable, 4278 .proc_handler = addrconf_sysctl_disable,
4345 .strategy = sysctl_intvec,
4346 }, 4279 },
4347 { 4280 {
4348 .ctl_name = CTL_UNNUMBERED,
4349 .procname = "accept_dad", 4281 .procname = "accept_dad",
4350 .data = &ipv6_devconf.accept_dad, 4282 .data = &ipv6_devconf.accept_dad,
4351 .maxlen = sizeof(int), 4283 .maxlen = sizeof(int),
@@ -4353,13 +4285,13 @@ static struct addrconf_sysctl_table
4353 .proc_handler = proc_dointvec, 4285 .proc_handler = proc_dointvec,
4354 }, 4286 },
4355 { 4287 {
4356 .ctl_name = 0, /* sentinel */ 4288 /* sentinel */
4357 } 4289 }
4358 }, 4290 },
4359}; 4291};
4360 4292
4361static int __addrconf_sysctl_register(struct net *net, char *dev_name, 4293static int __addrconf_sysctl_register(struct net *net, char *dev_name,
4362 int ctl_name, struct inet6_dev *idev, struct ipv6_devconf *p) 4294 struct inet6_dev *idev, struct ipv6_devconf *p)
4363{ 4295{
4364 int i; 4296 int i;
4365 struct addrconf_sysctl_table *t; 4297 struct addrconf_sysctl_table *t;
@@ -4367,9 +4299,9 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
4367#define ADDRCONF_CTL_PATH_DEV 3 4299#define ADDRCONF_CTL_PATH_DEV 3
4368 4300
4369 struct ctl_path addrconf_ctl_path[] = { 4301 struct ctl_path addrconf_ctl_path[] = {
4370 { .procname = "net", .ctl_name = CTL_NET, }, 4302 { .procname = "net", },
4371 { .procname = "ipv6", .ctl_name = NET_IPV6, }, 4303 { .procname = "ipv6", },
4372 { .procname = "conf", .ctl_name = NET_IPV6_CONF, }, 4304 { .procname = "conf", },
4373 { /* to be set */ }, 4305 { /* to be set */ },
4374 { }, 4306 { },
4375 }; 4307 };
@@ -4395,7 +4327,6 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
4395 goto free; 4327 goto free;
4396 4328
4397 addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].procname = t->dev_name; 4329 addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].procname = t->dev_name;
4398 addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].ctl_name = ctl_name;
4399 4330
4400 t->sysctl_header = register_net_sysctl_table(net, addrconf_ctl_path, 4331 t->sysctl_header = register_net_sysctl_table(net, addrconf_ctl_path,
4401 t->addrconf_vars); 4332 t->addrconf_vars);
@@ -4431,10 +4362,9 @@ static void addrconf_sysctl_register(struct inet6_dev *idev)
4431{ 4362{
4432 neigh_sysctl_register(idev->dev, idev->nd_parms, NET_IPV6, 4363 neigh_sysctl_register(idev->dev, idev->nd_parms, NET_IPV6,
4433 NET_IPV6_NEIGH, "ipv6", 4364 NET_IPV6_NEIGH, "ipv6",
4434 &ndisc_ifinfo_sysctl_change, 4365 &ndisc_ifinfo_sysctl_change);
4435 ndisc_ifinfo_sysctl_strategy);
4436 __addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name, 4366 __addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name,
4437 idev->dev->ifindex, idev, &idev->cnf); 4367 idev, &idev->cnf);
4438} 4368}
4439 4369
4440static void addrconf_sysctl_unregister(struct inet6_dev *idev) 4370static void addrconf_sysctl_unregister(struct inet6_dev *idev)
@@ -4473,13 +4403,11 @@ static int addrconf_init_net(struct net *net)
4473 net->ipv6.devconf_dflt = dflt; 4403 net->ipv6.devconf_dflt = dflt;
4474 4404
4475#ifdef CONFIG_SYSCTL 4405#ifdef CONFIG_SYSCTL
4476 err = __addrconf_sysctl_register(net, "all", NET_PROTO_CONF_ALL, 4406 err = __addrconf_sysctl_register(net, "all", NULL, all);
4477 NULL, all);
4478 if (err < 0) 4407 if (err < 0)
4479 goto err_reg_all; 4408 goto err_reg_all;
4480 4409
4481 err = __addrconf_sysctl_register(net, "default", NET_PROTO_CONF_DEFAULT, 4410 err = __addrconf_sysctl_register(net, "default", NULL, dflt);
4482 NULL, dflt);
4483 if (err < 0) 4411 if (err < 0)
4484 goto err_reg_dflt; 4412 goto err_reg_dflt;
4485#endif 4413#endif