aboutsummaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
Diffstat (limited to 'net/l2tp')
-rw-r--r--net/l2tp/l2tp_core.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index ecc7aea9efe4..1712af1c7b3f 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1617,14 +1617,9 @@ EXPORT_SYMBOL_GPL(l2tp_session_create);
1617 1617
1618static __net_init int l2tp_init_net(struct net *net) 1618static __net_init int l2tp_init_net(struct net *net)
1619{ 1619{
1620 struct l2tp_net *pn; 1620 struct l2tp_net *pn = net_generic(net, l2tp_net_id);
1621 int err;
1622 int hash; 1621 int hash;
1623 1622
1624 pn = kzalloc(sizeof(*pn), GFP_KERNEL);
1625 if (!pn)
1626 return -ENOMEM;
1627
1628 INIT_LIST_HEAD(&pn->l2tp_tunnel_list); 1623 INIT_LIST_HEAD(&pn->l2tp_tunnel_list);
1629 spin_lock_init(&pn->l2tp_tunnel_list_lock); 1624 spin_lock_init(&pn->l2tp_tunnel_list_lock);
1630 1625
@@ -1633,33 +1628,11 @@ static __net_init int l2tp_init_net(struct net *net)
1633 1628
1634 spin_lock_init(&pn->l2tp_session_hlist_lock); 1629 spin_lock_init(&pn->l2tp_session_hlist_lock);
1635 1630
1636 err = net_assign_generic(net, l2tp_net_id, pn);
1637 if (err)
1638 goto out;
1639
1640 return 0; 1631 return 0;
1641
1642out:
1643 kfree(pn);
1644 return err;
1645}
1646
1647static __net_exit void l2tp_exit_net(struct net *net)
1648{
1649 struct l2tp_net *pn;
1650
1651 pn = net_generic(net, l2tp_net_id);
1652 /*
1653 * if someone has cached our net then
1654 * further net_generic call will return NULL
1655 */
1656 net_assign_generic(net, l2tp_net_id, NULL);
1657 kfree(pn);
1658} 1632}
1659 1633
1660static struct pernet_operations l2tp_net_ops = { 1634static struct pernet_operations l2tp_net_ops = {
1661 .init = l2tp_init_net, 1635 .init = l2tp_init_net,
1662 .exit = l2tp_exit_net,
1663 .id = &l2tp_net_id, 1636 .id = &l2tp_net_id,
1664 .size = sizeof(struct l2tp_net), 1637 .size = sizeof(struct l2tp_net),
1665}; 1638};