Commit d2b3eb63 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

net: Simplify phonet pernet operations.

Take advantage of the new pernet automatic storage management,
and stop using compatibility network namespace functions.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aaab3405
...@@ -313,19 +313,14 @@ static struct notifier_block phonet_device_notifier = { ...@@ -313,19 +313,14 @@ static struct notifier_block phonet_device_notifier = {
/* Per-namespace Phonet devices handling */ /* Per-namespace Phonet devices handling */
static int phonet_init_net(struct net *net) static int phonet_init_net(struct net *net)
{ {
struct phonet_net *pnn = kzalloc(sizeof(*pnn), GFP_KERNEL); struct phonet_net *pnn = net_generic(net, phonet_net_id);
if (!pnn)
return -ENOMEM;
if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) { if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops))
kfree(pnn);
return -ENOMEM; return -ENOMEM;
}
INIT_LIST_HEAD(&pnn->pndevs.list); INIT_LIST_HEAD(&pnn->pndevs.list);
mutex_init(&pnn->pndevs.lock); mutex_init(&pnn->pndevs.lock);
mutex_init(&pnn->routes.lock); mutex_init(&pnn->routes.lock);
net_assign_generic(net, phonet_net_id, pnn);
return 0; return 0;
} }
...@@ -349,18 +344,19 @@ static void phonet_exit_net(struct net *net) ...@@ -349,18 +344,19 @@ static void phonet_exit_net(struct net *net)
rtnl_unlock(); rtnl_unlock();
proc_net_remove(net, "phonet"); proc_net_remove(net, "phonet");
kfree(pnn);
} }
static struct pernet_operations phonet_net_ops = { static struct pernet_operations phonet_net_ops = {
.init = phonet_init_net, .init = phonet_init_net,
.exit = phonet_exit_net, .exit = phonet_exit_net,
.id = &phonet_net_id,
.size = sizeof(struct phonet_net),
}; };
/* Initialize Phonet devices list */ /* Initialize Phonet devices list */
int __init phonet_device_init(void) int __init phonet_device_init(void)
{ {
int err = register_pernet_gen_device(&phonet_net_id, &phonet_net_ops); int err = register_pernet_device(&phonet_net_ops);
if (err) if (err)
return err; return err;
...@@ -375,7 +371,7 @@ void phonet_device_exit(void) ...@@ -375,7 +371,7 @@ void phonet_device_exit(void)
{ {
rtnl_unregister_all(PF_PHONET); rtnl_unregister_all(PF_PHONET);
unregister_netdevice_notifier(&phonet_device_notifier); unregister_netdevice_notifier(&phonet_device_notifier);
unregister_pernet_gen_device(phonet_net_id, &phonet_net_ops); unregister_pernet_device(&phonet_net_ops);
} }
int phonet_route_add(struct net_device *dev, u8 daddr) int phonet_route_add(struct net_device *dev, u8 daddr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment