diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-12-01 08:59:38 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:55:38 -0500 |
commit | 1dab62226dd9e0c0051229e7868363663546c772 (patch) | |
tree | 992540972ed762807c12f0dcbd7d4a56b86d2646 /net | |
parent | f52295a9c55ccb4d9b3580ce889f958ac740a44b (diff) |
[IPV6]: Use ctl paths to register addrconf sysctls
This looks very much like the patch for ipv4's devinet.
This is also intended to help us with the net namespaces
and saves the ipv6.ko size by ~320 bytes.
The difference from the first version is just the patch
offsets, that changed due to changes in the patch #2.
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')
-rw-r--r-- | net/ipv6/addrconf.c | 80 |
1 files changed, 20 insertions, 60 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index ea1673d29078..dbff389b7003 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -3848,10 +3848,7 @@ static struct addrconf_sysctl_table | |||
3848 | { | 3848 | { |
3849 | struct ctl_table_header *sysctl_header; | 3849 | struct ctl_table_header *sysctl_header; |
3850 | ctl_table addrconf_vars[__NET_IPV6_MAX]; | 3850 | ctl_table addrconf_vars[__NET_IPV6_MAX]; |
3851 | ctl_table addrconf_dev[2]; | 3851 | char *dev_name; |
3852 | ctl_table addrconf_conf_dir[2]; | ||
3853 | ctl_table addrconf_proto_dir[2]; | ||
3854 | ctl_table addrconf_root_dir[2]; | ||
3855 | } addrconf_sysctl __read_mostly = { | 3852 | } addrconf_sysctl __read_mostly = { |
3856 | .sysctl_header = NULL, | 3853 | .sysctl_header = NULL, |
3857 | .addrconf_vars = { | 3854 | .addrconf_vars = { |
@@ -4072,50 +4069,6 @@ static struct addrconf_sysctl_table | |||
4072 | .ctl_name = 0, /* sentinel */ | 4069 | .ctl_name = 0, /* sentinel */ |
4073 | } | 4070 | } |
4074 | }, | 4071 | }, |
4075 | .addrconf_dev = { | ||
4076 | { | ||
4077 | .ctl_name = NET_PROTO_CONF_ALL, | ||
4078 | .procname = "all", | ||
4079 | .mode = 0555, | ||
4080 | .child = addrconf_sysctl.addrconf_vars, | ||
4081 | }, | ||
4082 | { | ||
4083 | .ctl_name = 0, /* sentinel */ | ||
4084 | } | ||
4085 | }, | ||
4086 | .addrconf_conf_dir = { | ||
4087 | { | ||
4088 | .ctl_name = NET_IPV6_CONF, | ||
4089 | .procname = "conf", | ||
4090 | .mode = 0555, | ||
4091 | .child = addrconf_sysctl.addrconf_dev, | ||
4092 | }, | ||
4093 | { | ||
4094 | .ctl_name = 0, /* sentinel */ | ||
4095 | } | ||
4096 | }, | ||
4097 | .addrconf_proto_dir = { | ||
4098 | { | ||
4099 | .ctl_name = NET_IPV6, | ||
4100 | .procname = "ipv6", | ||
4101 | .mode = 0555, | ||
4102 | .child = addrconf_sysctl.addrconf_conf_dir, | ||
4103 | }, | ||
4104 | { | ||
4105 | .ctl_name = 0, /* sentinel */ | ||
4106 | } | ||
4107 | }, | ||
4108 | .addrconf_root_dir = { | ||
4109 | { | ||
4110 | .ctl_name = CTL_NET, | ||
4111 | .procname = "net", | ||
4112 | .mode = 0555, | ||
4113 | .child = addrconf_sysctl.addrconf_proto_dir, | ||
4114 | }, | ||
4115 | { | ||
4116 | .ctl_name = 0, /* sentinel */ | ||
4117 | } | ||
4118 | }, | ||
4119 | }; | 4072 | }; |
4120 | 4073 | ||
4121 | static void __addrconf_sysctl_register(char *dev_name, int ctl_name, | 4074 | static void __addrconf_sysctl_register(char *dev_name, int ctl_name, |
@@ -4124,6 +4077,17 @@ static void __addrconf_sysctl_register(char *dev_name, int ctl_name, | |||
4124 | int i; | 4077 | int i; |
4125 | struct addrconf_sysctl_table *t; | 4078 | struct addrconf_sysctl_table *t; |
4126 | 4079 | ||
4080 | #define ADDRCONF_CTL_PATH_DEV 3 | ||
4081 | |||
4082 | struct ctl_path addrconf_ctl_path[] = { | ||
4083 | { .procname = "net", .ctl_name = CTL_NET, }, | ||
4084 | { .procname = "ipv6", .ctl_name = NET_IPV6, }, | ||
4085 | { .procname = "conf", .ctl_name = NET_IPV6_CONF, }, | ||
4086 | { /* to be set */ }, | ||
4087 | { }, | ||
4088 | }; | ||
4089 | |||
4090 | |||
4127 | t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL); | 4091 | t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL); |
4128 | if (t == NULL) | 4092 | if (t == NULL) |
4129 | goto out; | 4093 | goto out; |
@@ -4138,19 +4102,15 @@ static void __addrconf_sysctl_register(char *dev_name, int ctl_name, | |||
4138 | * by sysctl and we wouldn't want anyone to change it under our feet | 4102 | * by sysctl and we wouldn't want anyone to change it under our feet |
4139 | * (see SIOCSIFNAME). | 4103 | * (see SIOCSIFNAME). |
4140 | */ | 4104 | */ |
4141 | dev_name = kstrdup(dev_name, GFP_KERNEL); | 4105 | t->dev_name = kstrdup(dev_name, GFP_KERNEL); |
4142 | if (!dev_name) | 4106 | if (!t->dev_name) |
4143 | goto free; | 4107 | goto free; |
4144 | 4108 | ||
4145 | t->addrconf_dev[0].ctl_name = ctl_name; | 4109 | addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].procname = t->dev_name; |
4146 | t->addrconf_dev[0].procname = dev_name; | 4110 | addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].ctl_name = ctl_name; |
4147 | |||
4148 | t->addrconf_dev[0].child = t->addrconf_vars; | ||
4149 | t->addrconf_conf_dir[0].child = t->addrconf_dev; | ||
4150 | t->addrconf_proto_dir[0].child = t->addrconf_conf_dir; | ||
4151 | t->addrconf_root_dir[0].child = t->addrconf_proto_dir; | ||
4152 | 4111 | ||
4153 | t->sysctl_header = register_sysctl_table(t->addrconf_root_dir); | 4112 | t->sysctl_header = register_sysctl_paths(addrconf_ctl_path, |
4113 | t->addrconf_vars); | ||
4154 | if (t->sysctl_header == NULL) | 4114 | if (t->sysctl_header == NULL) |
4155 | goto free_procname; | 4115 | goto free_procname; |
4156 | 4116 | ||
@@ -4158,7 +4118,7 @@ static void __addrconf_sysctl_register(char *dev_name, int ctl_name, | |||
4158 | return; | 4118 | return; |
4159 | 4119 | ||
4160 | free_procname: | 4120 | free_procname: |
4161 | kfree(dev_name); | 4121 | kfree(t->dev_name); |
4162 | free: | 4122 | free: |
4163 | kfree(t); | 4123 | kfree(t); |
4164 | out: | 4124 | out: |
@@ -4177,7 +4137,7 @@ static void addrconf_sysctl_unregister(struct ipv6_devconf *p) | |||
4177 | struct addrconf_sysctl_table *t = p->sysctl; | 4137 | struct addrconf_sysctl_table *t = p->sysctl; |
4178 | p->sysctl = NULL; | 4138 | p->sysctl = NULL; |
4179 | unregister_sysctl_table(t->sysctl_header); | 4139 | unregister_sysctl_table(t->sysctl_header); |
4180 | kfree(t->addrconf_dev[0].procname); | 4140 | kfree(t->dev_name); |
4181 | kfree(t); | 4141 | kfree(t); |
4182 | } | 4142 | } |
4183 | } | 4143 | } |