diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-12-01 08:58:37 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:55:38 -0500 |
commit | f52295a9c55ccb4d9b3580ce889f958ac740a44b (patch) | |
tree | c78f96914eba466c30172a7d02b7af9943e10d89 /net/ipv6/addrconf.c | |
parent | bfada697bd534d2c16fd07fbef3a4924c4d4e014 (diff) |
[IPV6]: Unify and cleanup calls to addrconf_sysctl_register
Currently this call is (ab)used similar to devinet one - it
registers sysctls for devices and for the "default" confs, while
the "all" sysctls are registered separately. But unlike its
devinet brother, the passed inet6_device is needed.
The fix is to make a __addrconf_sysctl_register(), which registers
sysctls for all "devices" we need, including "default" and "all" :)
The original addrconf_sysctl_register() calls the introduced
function, passing the inet6_device, device name and ifindex (to
be used as procname and ctl_name) into it.
Thanks to Herbert again for pointing out, that we can shrink the
argument list to 1 :)
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r-- | net/ipv6/addrconf.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 2d2886a0b66d..ea1673d29078 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -101,7 +101,7 @@ | |||
101 | #define TIME_DELTA(a,b) ((unsigned long)((long)(a) - (long)(b))) | 101 | #define TIME_DELTA(a,b) ((unsigned long)((long)(a) - (long)(b))) |
102 | 102 | ||
103 | #ifdef CONFIG_SYSCTL | 103 | #ifdef CONFIG_SYSCTL |
104 | static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf *p); | 104 | static void addrconf_sysctl_register(struct inet6_dev *idev); |
105 | static void addrconf_sysctl_unregister(struct ipv6_devconf *p); | 105 | static void addrconf_sysctl_unregister(struct ipv6_devconf *p); |
106 | #endif | 106 | #endif |
107 | 107 | ||
@@ -400,7 +400,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev) | |||
400 | NET_IPV6_NEIGH, "ipv6", | 400 | NET_IPV6_NEIGH, "ipv6", |
401 | &ndisc_ifinfo_sysctl_change, | 401 | &ndisc_ifinfo_sysctl_change, |
402 | NULL); | 402 | NULL); |
403 | addrconf_sysctl_register(ndev, &ndev->cnf); | 403 | addrconf_sysctl_register(ndev); |
404 | #endif | 404 | #endif |
405 | /* protected by rtnl_lock */ | 405 | /* protected by rtnl_lock */ |
406 | rcu_assign_pointer(dev->ip6_ptr, ndev); | 406 | rcu_assign_pointer(dev->ip6_ptr, ndev); |
@@ -2386,7 +2386,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, | |||
2386 | NET_IPV6, NET_IPV6_NEIGH, "ipv6", | 2386 | NET_IPV6, NET_IPV6_NEIGH, "ipv6", |
2387 | &ndisc_ifinfo_sysctl_change, | 2387 | &ndisc_ifinfo_sysctl_change, |
2388 | NULL); | 2388 | NULL); |
2389 | addrconf_sysctl_register(idev, &idev->cnf); | 2389 | addrconf_sysctl_register(idev); |
2390 | #endif | 2390 | #endif |
2391 | err = snmp6_register_dev(idev); | 2391 | err = snmp6_register_dev(idev); |
2392 | if (err) | 2392 | if (err) |
@@ -4118,12 +4118,11 @@ static struct addrconf_sysctl_table | |||
4118 | }, | 4118 | }, |
4119 | }; | 4119 | }; |
4120 | 4120 | ||
4121 | static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf *p) | 4121 | static void __addrconf_sysctl_register(char *dev_name, int ctl_name, |
4122 | struct inet6_dev *idev, struct ipv6_devconf *p) | ||
4122 | { | 4123 | { |
4123 | int i; | 4124 | int i; |
4124 | struct net_device *dev = idev ? idev->dev : NULL; | ||
4125 | struct addrconf_sysctl_table *t; | 4125 | struct addrconf_sysctl_table *t; |
4126 | char *dev_name = NULL; | ||
4127 | 4126 | ||
4128 | t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL); | 4127 | t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL); |
4129 | if (t == NULL) | 4128 | if (t == NULL) |
@@ -4133,13 +4132,6 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf | |||
4133 | t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf; | 4132 | t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf; |
4134 | t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */ | 4133 | t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */ |
4135 | } | 4134 | } |
4136 | if (dev) { | ||
4137 | dev_name = dev->name; | ||
4138 | t->addrconf_dev[0].ctl_name = dev->ifindex; | ||
4139 | } else { | ||
4140 | dev_name = "default"; | ||
4141 | t->addrconf_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT; | ||
4142 | } | ||
4143 | 4135 | ||
4144 | /* | 4136 | /* |
4145 | * Make a copy of dev_name, because '.procname' is regarded as const | 4137 | * Make a copy of dev_name, because '.procname' is regarded as const |
@@ -4150,6 +4142,7 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf | |||
4150 | if (!dev_name) | 4142 | if (!dev_name) |
4151 | goto free; | 4143 | goto free; |
4152 | 4144 | ||
4145 | t->addrconf_dev[0].ctl_name = ctl_name; | ||
4153 | t->addrconf_dev[0].procname = dev_name; | 4146 | t->addrconf_dev[0].procname = dev_name; |
4154 | 4147 | ||
4155 | t->addrconf_dev[0].child = t->addrconf_vars; | 4148 | t->addrconf_dev[0].child = t->addrconf_vars; |
@@ -4172,6 +4165,12 @@ out: | |||
4172 | return; | 4165 | return; |
4173 | } | 4166 | } |
4174 | 4167 | ||
4168 | static void addrconf_sysctl_register(struct inet6_dev *idev) | ||
4169 | { | ||
4170 | __addrconf_sysctl_register(idev->dev->name, idev->dev->ifindex, | ||
4171 | idev, &idev->cnf); | ||
4172 | } | ||
4173 | |||
4175 | static void addrconf_sysctl_unregister(struct ipv6_devconf *p) | 4174 | static void addrconf_sysctl_unregister(struct ipv6_devconf *p) |
4176 | { | 4175 | { |
4177 | if (p->sysctl) { | 4176 | if (p->sysctl) { |
@@ -4270,9 +4269,10 @@ int __init addrconf_init(void) | |||
4270 | ipv6_addr_label_rtnl_register(); | 4269 | ipv6_addr_label_rtnl_register(); |
4271 | 4270 | ||
4272 | #ifdef CONFIG_SYSCTL | 4271 | #ifdef CONFIG_SYSCTL |
4273 | addrconf_sysctl.sysctl_header = | 4272 | __addrconf_sysctl_register("all", NET_PROTO_CONF_ALL, |
4274 | register_sysctl_table(addrconf_sysctl.addrconf_root_dir); | 4273 | NULL, &ipv6_devconf); |
4275 | addrconf_sysctl_register(NULL, &ipv6_devconf_dflt); | 4274 | __addrconf_sysctl_register("default", NET_PROTO_CONF_DEFAULT, |
4275 | NULL, &ipv6_devconf_dflt); | ||
4276 | #endif | 4276 | #endif |
4277 | 4277 | ||
4278 | return 0; | 4278 | return 0; |