Skip to content

Commit 9f775ea

Browse files
Guillaume Naultdavem330
authored andcommitted
l2tp: fix l2tp_eth module loading
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: d9e31d1 ("l2tp: Add L2TP ethernet pseudowire support") Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c79c314 commit 9f775ea

File tree

1 file changed

+2
-49
lines changed

1 file changed

+2
-49
lines changed

net/l2tp/l2tp_eth.c

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct l2tp_eth {
4444
struct net_device *dev;
4545
struct sock *tunnel_sock;
4646
struct l2tp_session *session;
47-
struct list_head list;
4847
atomic_long_t tx_bytes;
4948
atomic_long_t tx_packets;
5049
atomic_long_t tx_dropped;
@@ -58,17 +57,6 @@ struct l2tp_eth_sess {
5857
struct net_device *dev;
5958
};
6059

61-
/* per-net private data for this module */
62-
static unsigned int l2tp_eth_net_id;
63-
struct l2tp_eth_net {
64-
struct list_head l2tp_eth_dev_list;
65-
spinlock_t l2tp_eth_lock;
66-
};
67-
68-
static inline struct l2tp_eth_net *l2tp_eth_pernet(struct net *net)
69-
{
70-
return net_generic(net, l2tp_eth_net_id);
71-
}
7260

7361
static int l2tp_eth_dev_init(struct net_device *dev)
7462
{
@@ -84,12 +72,6 @@ static int l2tp_eth_dev_init(struct net_device *dev)
8472

8573
static void l2tp_eth_dev_uninit(struct net_device *dev)
8674
{
87-
struct l2tp_eth *priv = netdev_priv(dev);
88-
struct l2tp_eth_net *pn = l2tp_eth_pernet(dev_net(dev));
89-
90-
spin_lock(&pn->l2tp_eth_lock);
91-
list_del_init(&priv->list);
92-
spin_unlock(&pn->l2tp_eth_lock);
9375
dev_put(dev);
9476
}
9577

@@ -273,7 +255,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
273255
struct l2tp_eth *priv;
274256
struct l2tp_eth_sess *spriv;
275257
int rc;
276-
struct l2tp_eth_net *pn;
277258

278259
if (cfg->ifname) {
279260
strlcpy(name, cfg->ifname, IFNAMSIZ);
@@ -305,7 +286,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
305286
priv = netdev_priv(dev);
306287
priv->dev = dev;
307288
priv->session = session;
308-
INIT_LIST_HEAD(&priv->list);
309289

310290
priv->tunnel_sock = tunnel->sock;
311291
session->recv_skb = l2tp_eth_dev_recv;
@@ -326,10 +306,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
326306
strlcpy(session->ifname, dev->name, IFNAMSIZ);
327307

328308
dev_hold(dev);
329-
pn = l2tp_eth_pernet(dev_net(dev));
330-
spin_lock(&pn->l2tp_eth_lock);
331-
list_add(&priv->list, &pn->l2tp_eth_dev_list);
332-
spin_unlock(&pn->l2tp_eth_lock);
333309

334310
return 0;
335311

@@ -342,22 +318,6 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
342318
return rc;
343319
}
344320

345-
static __net_init int l2tp_eth_init_net(struct net *net)
346-
{
347-
struct l2tp_eth_net *pn = net_generic(net, l2tp_eth_net_id);
348-
349-
INIT_LIST_HEAD(&pn->l2tp_eth_dev_list);
350-
spin_lock_init(&pn->l2tp_eth_lock);
351-
352-
return 0;
353-
}
354-
355-
static struct pernet_operations l2tp_eth_net_ops = {
356-
.init = l2tp_eth_init_net,
357-
.id = &l2tp_eth_net_id,
358-
.size = sizeof(struct l2tp_eth_net),
359-
};
360-
361321

362322
static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = {
363323
.session_create = l2tp_eth_create,
@@ -371,25 +331,18 @@ static int __init l2tp_eth_init(void)
371331

372332
err = l2tp_nl_register_ops(L2TP_PWTYPE_ETH, &l2tp_eth_nl_cmd_ops);
373333
if (err)
374-
goto out;
375-
376-
err = register_pernet_device(&l2tp_eth_net_ops);
377-
if (err)
378-
goto out_unreg;
334+
goto err;
379335

380336
pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
381337

382338
return 0;
383339

384-
out_unreg:
385-
l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH);
386-
out:
340+
err:
387341
return err;
388342
}
389343

390344
static void __exit l2tp_eth_exit(void)
391345
{
392-
unregister_pernet_device(&l2tp_eth_net_ops);
393346
l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH);
394347
}
395348

0 commit comments

Comments
 (0)