提交 6105e293 编写于 作者: E Eric W. Biederman 提交者: David S. Miller

net ipv6: Convert addrconf to use register_net_sysctl

Using an ascii path to register_net_sysctl as opposed to the slightly
awkward ctl_path allows for much simpler code.

We no longer need to malloc dev_name to keep it alive the length of our
sysctl register instead we can use a small temporary buffer on the
stack.
Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
Acked-by: NPavel Emelyanov <xemul@parallels.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9bdcc88f
...@@ -4365,7 +4365,6 @@ static struct addrconf_sysctl_table ...@@ -4365,7 +4365,6 @@ static struct addrconf_sysctl_table
{ {
struct ctl_table_header *sysctl_header; struct ctl_table_header *sysctl_header;
ctl_table addrconf_vars[DEVCONF_MAX+1]; ctl_table addrconf_vars[DEVCONF_MAX+1];
char *dev_name;
} addrconf_sysctl __read_mostly = { } addrconf_sysctl __read_mostly = {
.sysctl_header = NULL, .sysctl_header = NULL,
.addrconf_vars = { .addrconf_vars = {
...@@ -4594,17 +4593,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, ...@@ -4594,17 +4593,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
{ {
int i; int i;
struct addrconf_sysctl_table *t; struct addrconf_sysctl_table *t;
char path[sizeof("net/ipv6/conf/") + IFNAMSIZ];
#define ADDRCONF_CTL_PATH_DEV 3
struct ctl_path addrconf_ctl_path[] = {
{ .procname = "net", },
{ .procname = "ipv6", },
{ .procname = "conf", },
{ /* to be set */ },
{ },
};
t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL); t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL);
if (t == NULL) if (t == NULL)
...@@ -4616,27 +4605,15 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, ...@@ -4616,27 +4605,15 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
t->addrconf_vars[i].extra2 = net; t->addrconf_vars[i].extra2 = net;
} }
/* snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name);
* Make a copy of dev_name, because '.procname' is regarded as const
* by sysctl and we wouldn't want anyone to change it under our feet
* (see SIOCSIFNAME).
*/
t->dev_name = kstrdup(dev_name, GFP_KERNEL);
if (!t->dev_name)
goto free;
addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].procname = t->dev_name; t->sysctl_header = register_net_sysctl(net, path, t->addrconf_vars);
t->sysctl_header = register_net_sysctl_table(net, addrconf_ctl_path,
t->addrconf_vars);
if (t->sysctl_header == NULL) if (t->sysctl_header == NULL)
goto free_procname; goto free;
p->sysctl = t; p->sysctl = t;
return 0; return 0;
free_procname:
kfree(t->dev_name);
free: free:
kfree(t); kfree(t);
out: out:
...@@ -4653,7 +4630,6 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) ...@@ -4653,7 +4630,6 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
t = p->sysctl; t = p->sysctl;
p->sysctl = NULL; p->sysctl = NULL;
unregister_net_sysctl_table(t->sysctl_header); unregister_net_sysctl_table(t->sysctl_header);
kfree(t->dev_name);
kfree(t); kfree(t);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册