l2tp: fix l2tp_eth module loading
commit9f775ead5e
upstream. The l2tp_eth module crashes if its netlink callbacks are run when the pernet data aren't initialised. We should normally register_pernet_device() before the genl callbacks. However, the pernet data only maintain a list of l2tpeth interfaces, and this list is never used. So let's just drop pernet handling instead. Fixes:d9e31d17ce
("l2tp: Add L2TP ethernet pseudowire support") Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3ca5103262
commit
c30b34ce79
@ -44,7 +44,6 @@ struct l2tp_eth {
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct sock *tunnel_sock;
|
struct sock *tunnel_sock;
|
||||||
struct l2tp_session *session;
|
struct l2tp_session *session;
|
||||||
struct list_head list;
|
|
||||||
atomic_long_t tx_bytes;
|
atomic_long_t tx_bytes;
|
||||||
atomic_long_t tx_packets;
|
atomic_long_t tx_packets;
|
||||||
atomic_long_t tx_dropped;
|
atomic_long_t tx_dropped;
|
||||||
@ -58,17 +57,6 @@ struct l2tp_eth_sess {
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* per-net private data for this module */
|
|
||||||
static unsigned int l2tp_eth_net_id;
|
|
||||||
struct l2tp_eth_net {
|
|
||||||
struct list_head l2tp_eth_dev_list;
|
|
||||||
spinlock_t l2tp_eth_lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct l2tp_eth_net *l2tp_eth_pernet(struct net *net)
|
|
||||||
{
|
|
||||||
return net_generic(net, l2tp_eth_net_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct lock_class_key l2tp_eth_tx_busylock;
|
static struct lock_class_key l2tp_eth_tx_busylock;
|
||||||
static int l2tp_eth_dev_init(struct net_device *dev)
|
static int l2tp_eth_dev_init(struct net_device *dev)
|
||||||
@ -84,12 +72,6 @@ static int l2tp_eth_dev_init(struct net_device *dev)
|
|||||||
|
|
||||||
static void l2tp_eth_dev_uninit(struct net_device *dev)
|
static void l2tp_eth_dev_uninit(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct l2tp_eth *priv = netdev_priv(dev);
|
|
||||||
struct l2tp_eth_net *pn = l2tp_eth_pernet(dev_net(dev));
|
|
||||||
|
|
||||||
spin_lock(&pn->l2tp_eth_lock);
|
|
||||||
list_del_init(&priv->list);
|
|
||||||
spin_unlock(&pn->l2tp_eth_lock);
|
|
||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +248,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
|
|||||||
struct l2tp_eth *priv;
|
struct l2tp_eth *priv;
|
||||||
struct l2tp_eth_sess *spriv;
|
struct l2tp_eth_sess *spriv;
|
||||||
int rc;
|
int rc;
|
||||||
struct l2tp_eth_net *pn;
|
|
||||||
|
|
||||||
if (cfg->ifname) {
|
if (cfg->ifname) {
|
||||||
dev = dev_get_by_name(net, cfg->ifname);
|
dev = dev_get_by_name(net, cfg->ifname);
|
||||||
@ -299,7 +280,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
|
|||||||
priv = netdev_priv(dev);
|
priv = netdev_priv(dev);
|
||||||
priv->dev = dev;
|
priv->dev = dev;
|
||||||
priv->session = session;
|
priv->session = session;
|
||||||
INIT_LIST_HEAD(&priv->list);
|
|
||||||
|
|
||||||
priv->tunnel_sock = tunnel->sock;
|
priv->tunnel_sock = tunnel->sock;
|
||||||
session->recv_skb = l2tp_eth_dev_recv;
|
session->recv_skb = l2tp_eth_dev_recv;
|
||||||
@ -320,10 +300,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
|
|||||||
strlcpy(session->ifname, dev->name, IFNAMSIZ);
|
strlcpy(session->ifname, dev->name, IFNAMSIZ);
|
||||||
|
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
pn = l2tp_eth_pernet(dev_net(dev));
|
|
||||||
spin_lock(&pn->l2tp_eth_lock);
|
|
||||||
list_add(&priv->list, &pn->l2tp_eth_dev_list);
|
|
||||||
spin_unlock(&pn->l2tp_eth_lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -336,22 +312,6 @@ out:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __net_init int l2tp_eth_init_net(struct net *net)
|
|
||||||
{
|
|
||||||
struct l2tp_eth_net *pn = net_generic(net, l2tp_eth_net_id);
|
|
||||||
|
|
||||||
INIT_LIST_HEAD(&pn->l2tp_eth_dev_list);
|
|
||||||
spin_lock_init(&pn->l2tp_eth_lock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct pernet_operations l2tp_eth_net_ops = {
|
|
||||||
.init = l2tp_eth_init_net,
|
|
||||||
.id = &l2tp_eth_net_id,
|
|
||||||
.size = sizeof(struct l2tp_eth_net),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = {
|
static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = {
|
||||||
.session_create = l2tp_eth_create,
|
.session_create = l2tp_eth_create,
|
||||||
@ -365,25 +325,18 @@ static int __init l2tp_eth_init(void)
|
|||||||
|
|
||||||
err = l2tp_nl_register_ops(L2TP_PWTYPE_ETH, &l2tp_eth_nl_cmd_ops);
|
err = l2tp_nl_register_ops(L2TP_PWTYPE_ETH, &l2tp_eth_nl_cmd_ops);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto err;
|
||||||
|
|
||||||
err = register_pernet_device(&l2tp_eth_net_ops);
|
|
||||||
if (err)
|
|
||||||
goto out_unreg;
|
|
||||||
|
|
||||||
pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
|
pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_unreg:
|
err:
|
||||||
l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH);
|
|
||||||
out:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit l2tp_eth_exit(void)
|
static void __exit l2tp_eth_exit(void)
|
||||||
{
|
{
|
||||||
unregister_pernet_device(&l2tp_eth_net_ops);
|
|
||||||
l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH);
|
l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user