diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-29 10:46:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 19:15:56 -0500 |
commit | c879a6fcd6382415015e246b443dc2a1eab604dc (patch) | |
tree | 4c991e7a400773be7a8089dc40bb7c2bd26d5549 /drivers/net/pppoe.c | |
parent | 741a6fa210c5c8828af3819134f644842e0e9c09 (diff) |
net: Simplify pppoe pernet operations.
Take advantage of the new pernet automatic storage management,
and stop using compatibility network namespace functions.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pppoe.c')
-rw-r--r-- | drivers/net/pppoe.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index a1dcba255b06..a4ed776d823b 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -1139,59 +1139,37 @@ static struct pppox_proto pppoe_proto = { | |||
1139 | 1139 | ||
1140 | static __net_init int pppoe_init_net(struct net *net) | 1140 | static __net_init int pppoe_init_net(struct net *net) |
1141 | { | 1141 | { |
1142 | struct pppoe_net *pn; | 1142 | struct pppoe_net *pn = pppoe_pernet(net); |
1143 | struct proc_dir_entry *pde; | 1143 | struct proc_dir_entry *pde; |
1144 | int err; | ||
1145 | |||
1146 | pn = kzalloc(sizeof(*pn), GFP_KERNEL); | ||
1147 | if (!pn) | ||
1148 | return -ENOMEM; | ||
1149 | 1144 | ||
1150 | rwlock_init(&pn->hash_lock); | 1145 | rwlock_init(&pn->hash_lock); |
1151 | 1146 | ||
1152 | err = net_assign_generic(net, pppoe_net_id, pn); | ||
1153 | if (err) | ||
1154 | goto out; | ||
1155 | |||
1156 | pde = proc_net_fops_create(net, "pppoe", S_IRUGO, &pppoe_seq_fops); | 1147 | pde = proc_net_fops_create(net, "pppoe", S_IRUGO, &pppoe_seq_fops); |
1157 | #ifdef CONFIG_PROC_FS | 1148 | #ifdef CONFIG_PROC_FS |
1158 | if (!pde) { | 1149 | if (!pde) |
1159 | err = -ENOMEM; | 1150 | return -ENOMEM; |
1160 | goto out; | ||
1161 | } | ||
1162 | #endif | 1151 | #endif |
1163 | 1152 | ||
1164 | return 0; | 1153 | return 0; |
1165 | |||
1166 | out: | ||
1167 | kfree(pn); | ||
1168 | return err; | ||
1169 | } | 1154 | } |
1170 | 1155 | ||
1171 | static __net_exit void pppoe_exit_net(struct net *net) | 1156 | static __net_exit void pppoe_exit_net(struct net *net) |
1172 | { | 1157 | { |
1173 | struct pppoe_net *pn; | ||
1174 | |||
1175 | proc_net_remove(net, "pppoe"); | 1158 | proc_net_remove(net, "pppoe"); |
1176 | pn = net_generic(net, pppoe_net_id); | ||
1177 | /* | ||
1178 | * if someone has cached our net then | ||
1179 | * further net_generic call will return NULL | ||
1180 | */ | ||
1181 | net_assign_generic(net, pppoe_net_id, NULL); | ||
1182 | kfree(pn); | ||
1183 | } | 1159 | } |
1184 | 1160 | ||
1185 | static struct pernet_operations pppoe_net_ops = { | 1161 | static struct pernet_operations pppoe_net_ops = { |
1186 | .init = pppoe_init_net, | 1162 | .init = pppoe_init_net, |
1187 | .exit = pppoe_exit_net, | 1163 | .exit = pppoe_exit_net, |
1164 | .id = &pppoe_net_id, | ||
1165 | .size = sizeof(struct pppoe_net), | ||
1188 | }; | 1166 | }; |
1189 | 1167 | ||
1190 | static int __init pppoe_init(void) | 1168 | static int __init pppoe_init(void) |
1191 | { | 1169 | { |
1192 | int err; | 1170 | int err; |
1193 | 1171 | ||
1194 | err = register_pernet_gen_device(&pppoe_net_id, &pppoe_net_ops); | 1172 | err = register_pernet_device(&pppoe_net_ops); |
1195 | if (err) | 1173 | if (err) |
1196 | goto out; | 1174 | goto out; |
1197 | 1175 | ||
@@ -1212,7 +1190,7 @@ static int __init pppoe_init(void) | |||
1212 | out_unregister_pppoe_proto: | 1190 | out_unregister_pppoe_proto: |
1213 | proto_unregister(&pppoe_sk_proto); | 1191 | proto_unregister(&pppoe_sk_proto); |
1214 | out_unregister_net_ops: | 1192 | out_unregister_net_ops: |
1215 | unregister_pernet_gen_device(pppoe_net_id, &pppoe_net_ops); | 1193 | unregister_pernet_device(&pppoe_net_ops); |
1216 | out: | 1194 | out: |
1217 | return err; | 1195 | return err; |
1218 | } | 1196 | } |
@@ -1224,7 +1202,7 @@ static void __exit pppoe_exit(void) | |||
1224 | dev_remove_pack(&pppoes_ptype); | 1202 | dev_remove_pack(&pppoes_ptype); |
1225 | unregister_pppox_proto(PX_PROTO_OE); | 1203 | unregister_pppox_proto(PX_PROTO_OE); |
1226 | proto_unregister(&pppoe_sk_proto); | 1204 | proto_unregister(&pppoe_sk_proto); |
1227 | unregister_pernet_gen_device(pppoe_net_id, &pppoe_net_ops); | 1205 | unregister_pernet_device(&pppoe_net_ops); |
1228 | } | 1206 | } |
1229 | 1207 | ||
1230 | module_init(pppoe_init); | 1208 | module_init(pppoe_init); |