diff options
Diffstat (limited to 'net/ipv6/ip6_tunnel.c')
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index e5c0f6bb8314..d453d07b0dfe 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -1409,17 +1409,8 @@ static void ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) | |||
1409 | 1409 | ||
1410 | static int ip6_tnl_init_net(struct net *net) | 1410 | static int ip6_tnl_init_net(struct net *net) |
1411 | { | 1411 | { |
1412 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); | ||
1412 | int err; | 1413 | int err; |
1413 | struct ip6_tnl_net *ip6n; | ||
1414 | |||
1415 | err = -ENOMEM; | ||
1416 | ip6n = kzalloc(sizeof(struct ip6_tnl_net), GFP_KERNEL); | ||
1417 | if (ip6n == NULL) | ||
1418 | goto err_alloc; | ||
1419 | |||
1420 | err = net_assign_generic(net, ip6_tnl_net_id, ip6n); | ||
1421 | if (err < 0) | ||
1422 | goto err_assign; | ||
1423 | 1414 | ||
1424 | ip6n->tnls[0] = ip6n->tnls_wc; | 1415 | ip6n->tnls[0] = ip6n->tnls_wc; |
1425 | ip6n->tnls[1] = ip6n->tnls_r_l; | 1416 | ip6n->tnls[1] = ip6n->tnls_r_l; |
@@ -1442,27 +1433,23 @@ static int ip6_tnl_init_net(struct net *net) | |||
1442 | err_register: | 1433 | err_register: |
1443 | free_netdev(ip6n->fb_tnl_dev); | 1434 | free_netdev(ip6n->fb_tnl_dev); |
1444 | err_alloc_dev: | 1435 | err_alloc_dev: |
1445 | /* nothing */ | ||
1446 | err_assign: | ||
1447 | kfree(ip6n); | ||
1448 | err_alloc: | ||
1449 | return err; | 1436 | return err; |
1450 | } | 1437 | } |
1451 | 1438 | ||
1452 | static void ip6_tnl_exit_net(struct net *net) | 1439 | static void ip6_tnl_exit_net(struct net *net) |
1453 | { | 1440 | { |
1454 | struct ip6_tnl_net *ip6n; | 1441 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
1455 | 1442 | ||
1456 | ip6n = net_generic(net, ip6_tnl_net_id); | ||
1457 | rtnl_lock(); | 1443 | rtnl_lock(); |
1458 | ip6_tnl_destroy_tunnels(ip6n); | 1444 | ip6_tnl_destroy_tunnels(ip6n); |
1459 | rtnl_unlock(); | 1445 | rtnl_unlock(); |
1460 | kfree(ip6n); | ||
1461 | } | 1446 | } |
1462 | 1447 | ||
1463 | static struct pernet_operations ip6_tnl_net_ops = { | 1448 | static struct pernet_operations ip6_tnl_net_ops = { |
1464 | .init = ip6_tnl_init_net, | 1449 | .init = ip6_tnl_init_net, |
1465 | .exit = ip6_tnl_exit_net, | 1450 | .exit = ip6_tnl_exit_net, |
1451 | .id = &ip6_tnl_net_id, | ||
1452 | .size = sizeof(struct ip6_tnl_net), | ||
1466 | }; | 1453 | }; |
1467 | 1454 | ||
1468 | /** | 1455 | /** |
@@ -1487,7 +1474,7 @@ static int __init ip6_tunnel_init(void) | |||
1487 | goto unreg_ip4ip6; | 1474 | goto unreg_ip4ip6; |
1488 | } | 1475 | } |
1489 | 1476 | ||
1490 | err = register_pernet_gen_device(&ip6_tnl_net_id, &ip6_tnl_net_ops); | 1477 | err = register_pernet_device(&ip6_tnl_net_ops); |
1491 | if (err < 0) | 1478 | if (err < 0) |
1492 | goto err_pernet; | 1479 | goto err_pernet; |
1493 | return 0; | 1480 | return 0; |
@@ -1511,7 +1498,7 @@ static void __exit ip6_tunnel_cleanup(void) | |||
1511 | if (xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6)) | 1498 | if (xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6)) |
1512 | printk(KERN_INFO "ip6_tunnel close: can't deregister ip6ip6\n"); | 1499 | printk(KERN_INFO "ip6_tunnel close: can't deregister ip6ip6\n"); |
1513 | 1500 | ||
1514 | unregister_pernet_gen_device(ip6_tnl_net_id, &ip6_tnl_net_ops); | 1501 | unregister_pernet_device(&ip6_tnl_net_ops); |
1515 | } | 1502 | } |
1516 | 1503 | ||
1517 | module_init(ip6_tunnel_init); | 1504 | module_init(ip6_tunnel_init); |