diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-29 10:46:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 19:15:57 -0500 |
commit | cfb8fbf2299d0e028ac59afd5b8c94ebe53d0859 (patch) | |
tree | 6becbcb1bb99ea946942d2205a1feba85bcff718 /net | |
parent | d2b3eb630767f0b0ae21566b1b88cb512f40c647 (diff) |
net: Simplify ip_gre 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 'net')
-rw-r--r-- | net/ipv4/ip_gre.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index c5f6af5d0f34..f36ce156cac6 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -1309,17 +1309,8 @@ static void ipgre_destroy_tunnels(struct ipgre_net *ign, struct list_head *head) | |||
1309 | 1309 | ||
1310 | static int ipgre_init_net(struct net *net) | 1310 | static int ipgre_init_net(struct net *net) |
1311 | { | 1311 | { |
1312 | struct ipgre_net *ign = net_generic(net, ipgre_net_id); | ||
1312 | int err; | 1313 | int err; |
1313 | struct ipgre_net *ign; | ||
1314 | |||
1315 | err = -ENOMEM; | ||
1316 | ign = kzalloc(sizeof(struct ipgre_net), GFP_KERNEL); | ||
1317 | if (ign == NULL) | ||
1318 | goto err_alloc; | ||
1319 | |||
1320 | err = net_assign_generic(net, ipgre_net_id, ign); | ||
1321 | if (err < 0) | ||
1322 | goto err_assign; | ||
1323 | 1314 | ||
1324 | ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "gre0", | 1315 | ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "gre0", |
1325 | ipgre_tunnel_setup); | 1316 | ipgre_tunnel_setup); |
@@ -1340,10 +1331,6 @@ static int ipgre_init_net(struct net *net) | |||
1340 | err_reg_dev: | 1331 | err_reg_dev: |
1341 | free_netdev(ign->fb_tunnel_dev); | 1332 | free_netdev(ign->fb_tunnel_dev); |
1342 | err_alloc_dev: | 1333 | err_alloc_dev: |
1343 | /* nothing */ | ||
1344 | err_assign: | ||
1345 | kfree(ign); | ||
1346 | err_alloc: | ||
1347 | return err; | 1334 | return err; |
1348 | } | 1335 | } |
1349 | 1336 | ||
@@ -1357,12 +1344,13 @@ static void ipgre_exit_net(struct net *net) | |||
1357 | ipgre_destroy_tunnels(ign, &list); | 1344 | ipgre_destroy_tunnels(ign, &list); |
1358 | unregister_netdevice_many(&list); | 1345 | unregister_netdevice_many(&list); |
1359 | rtnl_unlock(); | 1346 | rtnl_unlock(); |
1360 | kfree(ign); | ||
1361 | } | 1347 | } |
1362 | 1348 | ||
1363 | static struct pernet_operations ipgre_net_ops = { | 1349 | static struct pernet_operations ipgre_net_ops = { |
1364 | .init = ipgre_init_net, | 1350 | .init = ipgre_init_net, |
1365 | .exit = ipgre_exit_net, | 1351 | .exit = ipgre_exit_net, |
1352 | .id = &ipgre_net_id, | ||
1353 | .size = sizeof(struct ipgre_net), | ||
1366 | }; | 1354 | }; |
1367 | 1355 | ||
1368 | static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[]) | 1356 | static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[]) |
@@ -1682,7 +1670,7 @@ static int __init ipgre_init(void) | |||
1682 | return -EAGAIN; | 1670 | return -EAGAIN; |
1683 | } | 1671 | } |
1684 | 1672 | ||
1685 | err = register_pernet_gen_device(&ipgre_net_id, &ipgre_net_ops); | 1673 | err = register_pernet_device(&ipgre_net_ops); |
1686 | if (err < 0) | 1674 | if (err < 0) |
1687 | goto gen_device_failed; | 1675 | goto gen_device_failed; |
1688 | 1676 | ||
@@ -1700,7 +1688,7 @@ out: | |||
1700 | tap_ops_failed: | 1688 | tap_ops_failed: |
1701 | rtnl_link_unregister(&ipgre_link_ops); | 1689 | rtnl_link_unregister(&ipgre_link_ops); |
1702 | rtnl_link_failed: | 1690 | rtnl_link_failed: |
1703 | unregister_pernet_gen_device(ipgre_net_id, &ipgre_net_ops); | 1691 | unregister_pernet_device(&ipgre_net_ops); |
1704 | gen_device_failed: | 1692 | gen_device_failed: |
1705 | inet_del_protocol(&ipgre_protocol, IPPROTO_GRE); | 1693 | inet_del_protocol(&ipgre_protocol, IPPROTO_GRE); |
1706 | goto out; | 1694 | goto out; |
@@ -1710,7 +1698,7 @@ static void __exit ipgre_fini(void) | |||
1710 | { | 1698 | { |
1711 | rtnl_link_unregister(&ipgre_tap_ops); | 1699 | rtnl_link_unregister(&ipgre_tap_ops); |
1712 | rtnl_link_unregister(&ipgre_link_ops); | 1700 | rtnl_link_unregister(&ipgre_link_ops); |
1713 | unregister_pernet_gen_device(ipgre_net_id, &ipgre_net_ops); | 1701 | unregister_pernet_device(&ipgre_net_ops); |
1714 | if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) | 1702 | if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) |
1715 | printk(KERN_INFO "ipgre close: can't remove protocol\n"); | 1703 | printk(KERN_INFO "ipgre close: can't remove protocol\n"); |
1716 | } | 1704 | } |