[PATCH 07/20] net: Simplify the bond drivers pernet operations.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric W. Biederman
Date: Sunday, November 29, 2009 - 6:46 pm

From: Eric W. Biederman <ebiederm@xmission.com>

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>
---
 drivers/net/bonding/bond_main.c |   32 +++++++++-----------------------
 1 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 726bd75..ac3fe20 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -5103,42 +5103,28 @@ out_netdev:
 
 static int bond_net_init(struct net *net)
 {
-	struct bond_net *bn;
-	int err;
-
-	err = -ENOMEM;
-	bn = kzalloc(sizeof(struct bond_net), GFP_KERNEL);
-	if (bn == NULL)
-		goto out;
+	struct bond_net *bn = net_generic(net, bond_net_id);
 
 	bn->net = net;
 	INIT_LIST_HEAD(&bn->dev_list);
 
-	err = net_assign_generic(net, bond_net_id, bn);
-	if (err)
-		goto out_free;
-
 	bond_create_proc_dir(bn);
-out:
-	return err;
-out_free:
-	kfree(bn);
-	goto out;
+	
+	return 0;
 }
 
 static void bond_net_exit(struct net *net)
 {
-	struct bond_net *bn;
-
-	bn = net_generic(net, bond_net_id);
+	struct bond_net *bn = net_generic(net, bond_net_id);
 
 	bond_destroy_proc_dir(bn);
-	kfree(bn);
 }
 
 static struct pernet_operations bond_net_ops = {
 	.init = bond_net_init,
 	.exit = bond_net_exit,
+	.id   = &bond_net_id,
+	.size = sizeof(struct bond_net),
 };
 
 static int __init bonding_init(void)
@@ -5152,7 +5138,7 @@ static int __init bonding_init(void)
 	if (res)
 		goto out;
 
-	res = register_pernet_gen_subsys(&bond_net_id, &bond_net_ops);
+	res = register_pernet_subsys(&bond_net_ops);
 	if (res)
 		goto out;
 
@@ -5178,7 +5164,7 @@ out:
 err:
 	rtnl_link_unregister(&bond_link_ops);
 err_link:
-	unregister_pernet_gen_subsys(bond_net_id, &bond_net_ops);
+	unregister_pernet_subsys(&bond_net_ops);
 	goto out;
 
 }
@@ -5192,7 +5178,7 @@ static void __exit bonding_exit(void)
 	bond_destroy_sysfs();
 
 	rtnl_link_unregister(&bond_link_ops);
-	unregister_pernet_gen_subsys(bond_net_id, &bond_net_ops);
+	unregister_pernet_subsys(&bond_net_ops);
 }
 
 module_init(bonding_init);
-- 
1.6.5.2.143.g8cc62

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 07/20] net: Simplify the bond drivers pernet operat ..., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 08/20] net: Simplify vlan pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 09/20] net: Simplify af_key pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 10/20] net: Simplify conntrack_proto_dccp pernet op ..., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 11/20] net: Simplify conntrack_proto_gre pernet ope ..., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 12/20] net: Simplify ppp_generic pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 13/20] net: Simplify pppoe pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 14/20] net: Simplify pppol2tp pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 15/20] net: Simplify phonet pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 16/20] net: Simplify ip_gre pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 17/20] net: Simplify ipip pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 18/20] net: Simplify ip6_tunnel pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 19/20] net: Simplify ipip6 aka sit pernet operations., Eric W. Biederman, (Sun Nov 29, 6:46 pm)
[PATCH 20/20] net: remove [un]register_pernet_gen_... and ..., Eric W. Biederman, (Sun Nov 29, 6:46 pm)