xref: /openbmc/linux/net/l2tp/l2tp_eth.c (revision e0d77d0f38aa60ca61b3ce6e60d64fad2aa0853d)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
220dcb110STom Parkin /* L2TPv3 ethernet pseudowire driver
3d9e31d17SJames Chapman  *
4d9e31d17SJames Chapman  * Copyright (c) 2008,2009,2010 Katalix Systems Ltd
5d9e31d17SJames Chapman  */
6d9e31d17SJames Chapman 
7a4ca44faSJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8a4ca44faSJoe Perches 
9d9e31d17SJames Chapman #include <linux/module.h>
10d9e31d17SJames Chapman #include <linux/skbuff.h>
11d9e31d17SJames Chapman #include <linux/socket.h>
12d9e31d17SJames Chapman #include <linux/hash.h>
13d9e31d17SJames Chapman #include <linux/l2tp.h>
14d9e31d17SJames Chapman #include <linux/in.h>
15d9e31d17SJames Chapman #include <linux/etherdevice.h>
16d9e31d17SJames Chapman #include <linux/spinlock.h>
17d9e31d17SJames Chapman #include <net/sock.h>
18d9e31d17SJames Chapman #include <net/ip.h>
19d9e31d17SJames Chapman #include <net/icmp.h>
20d9e31d17SJames Chapman #include <net/udp.h>
21d9e31d17SJames Chapman #include <net/inet_common.h>
22d9e31d17SJames Chapman #include <net/inet_hashtables.h>
23d9e31d17SJames Chapman #include <net/tcp_states.h>
24d9e31d17SJames Chapman #include <net/protocol.h>
25d9e31d17SJames Chapman #include <net/xfrm.h>
26d9e31d17SJames Chapman #include <net/net_namespace.h>
27d9e31d17SJames Chapman #include <net/netns/generic.h>
28b784e7ebSR. Parameswaran #include <linux/ip.h>
29b784e7ebSR. Parameswaran #include <linux/ipv6.h>
30b784e7ebSR. Parameswaran #include <linux/udp.h>
31d9e31d17SJames Chapman 
32d9e31d17SJames Chapman #include "l2tp_core.h"
33d9e31d17SJames Chapman 
34d9e31d17SJames Chapman /* Default device name. May be overridden by name specified by user */
35d9e31d17SJames Chapman #define L2TP_ETH_DEV_NAME	"l2tpeth%d"
36d9e31d17SJames Chapman 
37d9e31d17SJames Chapman /* via netdev_priv() */
38d9e31d17SJames Chapman struct l2tp_eth {
39d9e31d17SJames Chapman 	struct l2tp_session	*session;
40a2842a1eSEric Dumazet 	atomic_long_t		tx_bytes;
41a2842a1eSEric Dumazet 	atomic_long_t		tx_packets;
42b8c84307SEric Dumazet 	atomic_long_t		tx_dropped;
43a2842a1eSEric Dumazet 	atomic_long_t		rx_bytes;
44a2842a1eSEric Dumazet 	atomic_long_t		rx_packets;
45a2842a1eSEric Dumazet 	atomic_long_t		rx_errors;
46d9e31d17SJames Chapman };
47d9e31d17SJames Chapman 
48d9e31d17SJames Chapman /* via l2tp_session_priv() */
49d9e31d17SJames Chapman struct l2tp_eth_sess {
50ee28de6bSGuillaume Nault 	struct net_device __rcu *dev;
51d9e31d17SJames Chapman };
52d9e31d17SJames Chapman 
l2tp_eth_dev_init(struct net_device * dev)53d9e31d17SJames Chapman static int l2tp_eth_dev_init(struct net_device *dev)
54d9e31d17SJames Chapman {
55f2cedb63SDanny Kukawka 	eth_hw_addr_random(dev);
561cea7e2cSJoe Perches 	eth_broadcast_addr(dev->broadcast);
571a33e10eSCong Wang 	netdev_lockdep_set_classes(dev);
58f9eb8aeaSEric Dumazet 
59d9e31d17SJames Chapman 	return 0;
60d9e31d17SJames Chapman }
61d9e31d17SJames Chapman 
l2tp_eth_dev_uninit(struct net_device * dev)62d9e31d17SJames Chapman static void l2tp_eth_dev_uninit(struct net_device *dev)
63d9e31d17SJames Chapman {
64ee28de6bSGuillaume Nault 	struct l2tp_eth *priv = netdev_priv(dev);
65ee28de6bSGuillaume Nault 	struct l2tp_eth_sess *spriv;
66ee28de6bSGuillaume Nault 
67ee28de6bSGuillaume Nault 	spriv = l2tp_session_priv(priv->session);
68ee28de6bSGuillaume Nault 	RCU_INIT_POINTER(spriv->dev, NULL);
69ee28de6bSGuillaume Nault 	/* No need for synchronize_net() here. We're called by
70ee28de6bSGuillaume Nault 	 * unregister_netdev*(), which does the synchronisation for us.
71ee28de6bSGuillaume Nault 	 */
72d9e31d17SJames Chapman }
73d9e31d17SJames Chapman 
l2tp_eth_dev_xmit(struct sk_buff * skb,struct net_device * dev)74433f17a9SLuc Van Oostenryck static netdev_tx_t l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
75d9e31d17SJames Chapman {
76d9e31d17SJames Chapman 	struct l2tp_eth *priv = netdev_priv(dev);
77d9e31d17SJames Chapman 	struct l2tp_session *session = priv->session;
78b8c84307SEric Dumazet 	unsigned int len = skb->len;
79efe05278STom Parkin 	int ret = l2tp_xmit_skb(session, skb);
80d9e31d17SJames Chapman 
81a4cd0271SWANG Cong 	if (likely(ret == NET_XMIT_SUCCESS)) {
82b8c84307SEric Dumazet 		atomic_long_add(len, &priv->tx_bytes);
83a2842a1eSEric Dumazet 		atomic_long_inc(&priv->tx_packets);
84b8c84307SEric Dumazet 	} else {
85b8c84307SEric Dumazet 		atomic_long_inc(&priv->tx_dropped);
86b8c84307SEric Dumazet 	}
87aa214de0SEric Dumazet 	return NETDEV_TX_OK;
88d9e31d17SJames Chapman }
89d9e31d17SJames Chapman 
l2tp_eth_get_stats64(struct net_device * dev,struct rtnl_link_stats64 * stats)90bc1f4470Sstephen hemminger static void l2tp_eth_get_stats64(struct net_device *dev,
91a2842a1eSEric Dumazet 				 struct rtnl_link_stats64 *stats)
92a2842a1eSEric Dumazet {
93a2842a1eSEric Dumazet 	struct l2tp_eth *priv = netdev_priv(dev);
94a2842a1eSEric Dumazet 
959b3dc0a1SDominik Heidler 	stats->tx_bytes   = (unsigned long)atomic_long_read(&priv->tx_bytes);
969b3dc0a1SDominik Heidler 	stats->tx_packets = (unsigned long)atomic_long_read(&priv->tx_packets);
979b3dc0a1SDominik Heidler 	stats->tx_dropped = (unsigned long)atomic_long_read(&priv->tx_dropped);
989b3dc0a1SDominik Heidler 	stats->rx_bytes   = (unsigned long)atomic_long_read(&priv->rx_bytes);
999b3dc0a1SDominik Heidler 	stats->rx_packets = (unsigned long)atomic_long_read(&priv->rx_packets);
1009b3dc0a1SDominik Heidler 	stats->rx_errors  = (unsigned long)atomic_long_read(&priv->rx_errors);
101a2842a1eSEric Dumazet }
102a2842a1eSEric Dumazet 
103eb94737dSJulia Lawall static const struct net_device_ops l2tp_eth_netdev_ops = {
104d9e31d17SJames Chapman 	.ndo_init		= l2tp_eth_dev_init,
105d9e31d17SJames Chapman 	.ndo_uninit		= l2tp_eth_dev_uninit,
106d9e31d17SJames Chapman 	.ndo_start_xmit		= l2tp_eth_dev_xmit,
107a2842a1eSEric Dumazet 	.ndo_get_stats64	= l2tp_eth_get_stats64,
108fe159122SAlexander Couzens 	.ndo_set_mac_address	= eth_mac_addr,
109d9e31d17SJames Chapman };
110d9e31d17SJames Chapman 
111a485c2b8SGuillaume Nault static struct device_type l2tpeth_type = {
112a485c2b8SGuillaume Nault 	.name = "l2tpeth",
113a485c2b8SGuillaume Nault };
114a485c2b8SGuillaume Nault 
l2tp_eth_dev_setup(struct net_device * dev)115d9e31d17SJames Chapman static void l2tp_eth_dev_setup(struct net_device *dev)
116d9e31d17SJames Chapman {
117a485c2b8SGuillaume Nault 	SET_NETDEV_DEVTYPE(dev, &l2tpeth_type);
118d9e31d17SJames Chapman 	ether_setup(dev);
119550fd08cSNeil Horman 	dev->priv_flags		&= ~IFF_TX_SKB_SHARING;
120a2842a1eSEric Dumazet 	dev->features		|= NETIF_F_LLTX;
121d9e31d17SJames Chapman 	dev->netdev_ops		= &l2tp_eth_netdev_ops;
122cf124db5SDavid S. Miller 	dev->needs_free_netdev	= true;
123d9e31d17SJames Chapman }
124d9e31d17SJames Chapman 
l2tp_eth_dev_recv(struct l2tp_session * session,struct sk_buff * skb,int data_len)125d9e31d17SJames Chapman static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
126d9e31d17SJames Chapman {
127d9e31d17SJames Chapman 	struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
128ee28de6bSGuillaume Nault 	struct net_device *dev;
129ee28de6bSGuillaume Nault 	struct l2tp_eth *priv;
130d9e31d17SJames Chapman 
131c0cc88a7SEric Dumazet 	if (!pskb_may_pull(skb, ETH_HLEN))
132d9e31d17SJames Chapman 		goto error;
133d9e31d17SJames Chapman 
134d9e31d17SJames Chapman 	secpath_reset(skb);
135d9e31d17SJames Chapman 
136d9e31d17SJames Chapman 	/* checksums verified by L2TP */
137d9e31d17SJames Chapman 	skb->ip_summed = CHECKSUM_NONE;
138d9e31d17SJames Chapman 
139*23e25d2fSDavid Bauer 	/* drop outer flow-hash */
140*23e25d2fSDavid Bauer 	skb_clear_hash(skb);
141*23e25d2fSDavid Bauer 
142d9e31d17SJames Chapman 	skb_dst_drop(skb);
143895b5c9fSFlorian Westphal 	nf_reset_ct(skb);
144d9e31d17SJames Chapman 
145ee28de6bSGuillaume Nault 	rcu_read_lock();
146ee28de6bSGuillaume Nault 	dev = rcu_dereference(spriv->dev);
147ee28de6bSGuillaume Nault 	if (!dev)
148ee28de6bSGuillaume Nault 		goto error_rcu;
149ee28de6bSGuillaume Nault 
150ee28de6bSGuillaume Nault 	priv = netdev_priv(dev);
151d9e31d17SJames Chapman 	if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
152a2842a1eSEric Dumazet 		atomic_long_inc(&priv->rx_packets);
153a2842a1eSEric Dumazet 		atomic_long_add(data_len, &priv->rx_bytes);
154a2842a1eSEric Dumazet 	} else {
155a2842a1eSEric Dumazet 		atomic_long_inc(&priv->rx_errors);
156a2842a1eSEric Dumazet 	}
157ee28de6bSGuillaume Nault 	rcu_read_unlock();
158ee28de6bSGuillaume Nault 
159d9e31d17SJames Chapman 	return;
160d9e31d17SJames Chapman 
161ee28de6bSGuillaume Nault error_rcu:
162ee28de6bSGuillaume Nault 	rcu_read_unlock();
163d9e31d17SJames Chapman error:
164d9e31d17SJames Chapman 	kfree_skb(skb);
165d9e31d17SJames Chapman }
166d9e31d17SJames Chapman 
l2tp_eth_delete(struct l2tp_session * session)167d9e31d17SJames Chapman static void l2tp_eth_delete(struct l2tp_session *session)
168d9e31d17SJames Chapman {
169d9e31d17SJames Chapman 	struct l2tp_eth_sess *spriv;
170d9e31d17SJames Chapman 	struct net_device *dev;
171d9e31d17SJames Chapman 
172d9e31d17SJames Chapman 	if (session) {
173d9e31d17SJames Chapman 		spriv = l2tp_session_priv(session);
174ee28de6bSGuillaume Nault 
175ee28de6bSGuillaume Nault 		rtnl_lock();
176ee28de6bSGuillaume Nault 		dev = rtnl_dereference(spriv->dev);
177d9e31d17SJames Chapman 		if (dev) {
178ee28de6bSGuillaume Nault 			unregister_netdevice(dev);
179ee28de6bSGuillaume Nault 			rtnl_unlock();
180a06998b8SEric Dumazet 			module_put(THIS_MODULE);
181ee28de6bSGuillaume Nault 		} else {
182ee28de6bSGuillaume Nault 			rtnl_unlock();
183d9e31d17SJames Chapman 		}
184d9e31d17SJames Chapman 	}
185d9e31d17SJames Chapman }
186d9e31d17SJames Chapman 
l2tp_eth_show(struct seq_file * m,void * arg)1870ad66140SJames Chapman static void l2tp_eth_show(struct seq_file *m, void *arg)
1880ad66140SJames Chapman {
1890ad66140SJames Chapman 	struct l2tp_session *session = arg;
1900ad66140SJames Chapman 	struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
191ee28de6bSGuillaume Nault 	struct net_device *dev;
192ee28de6bSGuillaume Nault 
193ee28de6bSGuillaume Nault 	rcu_read_lock();
194ee28de6bSGuillaume Nault 	dev = rcu_dereference(spriv->dev);
195ee28de6bSGuillaume Nault 	if (!dev) {
196ee28de6bSGuillaume Nault 		rcu_read_unlock();
197ee28de6bSGuillaume Nault 		return;
198ee28de6bSGuillaume Nault 	}
199ee28de6bSGuillaume Nault 	dev_hold(dev);
200ee28de6bSGuillaume Nault 	rcu_read_unlock();
2010ad66140SJames Chapman 
2020ad66140SJames Chapman 	seq_printf(m, "   interface %s\n", dev->name);
203ee28de6bSGuillaume Nault 
204ee28de6bSGuillaume Nault 	dev_put(dev);
2050ad66140SJames Chapman }
2060ad66140SJames Chapman 
l2tp_eth_adjust_mtu(struct l2tp_tunnel * tunnel,struct l2tp_session * session,struct net_device * dev)207b784e7ebSR. Parameswaran static void l2tp_eth_adjust_mtu(struct l2tp_tunnel *tunnel,
208b784e7ebSR. Parameswaran 				struct l2tp_session *session,
209b784e7ebSR. Parameswaran 				struct net_device *dev)
210b784e7ebSR. Parameswaran {
211b784e7ebSR. Parameswaran 	unsigned int overhead = 0;
212b784e7ebSR. Parameswaran 	u32 l3_overhead = 0;
2131f5cd2a0SGuillaume Nault 	u32 mtu;
214b784e7ebSR. Parameswaran 
215b784e7ebSR. Parameswaran 	/* if the encap is UDP, account for UDP header size */
216b784e7ebSR. Parameswaran 	if (tunnel->encap == L2TP_ENCAPTYPE_UDP) {
217b784e7ebSR. Parameswaran 		overhead += sizeof(struct udphdr);
218b784e7ebSR. Parameswaran 		dev->needed_headroom += sizeof(struct udphdr);
219b784e7ebSR. Parameswaran 	}
220e9697e2eSGuillaume Nault 
22157240d00SR. Parameswaran 	lock_sock(tunnel->sock);
222b784e7ebSR. Parameswaran 	l3_overhead = kernel_sock_ip_overhead(tunnel->sock);
22357240d00SR. Parameswaran 	release_sock(tunnel->sock);
224e9697e2eSGuillaume Nault 
225b784e7ebSR. Parameswaran 	if (l3_overhead == 0) {
226b784e7ebSR. Parameswaran 		/* L3 Overhead couldn't be identified, this could be
227b784e7ebSR. Parameswaran 		 * because tunnel->sock was NULL or the socket's
228b784e7ebSR. Parameswaran 		 * address family was not IPv4 or IPv6,
229b784e7ebSR. Parameswaran 		 * dev mtu stays at 1500.
230b784e7ebSR. Parameswaran 		 */
231b784e7ebSR. Parameswaran 		return;
232b784e7ebSR. Parameswaran 	}
233b784e7ebSR. Parameswaran 	/* Adjust MTU, factor overhead - underlay L3, overlay L2 hdr
234b784e7ebSR. Parameswaran 	 * UDP overhead, if any, was already factored in above.
235b784e7ebSR. Parameswaran 	 */
236b784e7ebSR. Parameswaran 	overhead += session->hdr_len + ETH_HLEN + l3_overhead;
237b784e7ebSR. Parameswaran 
238e9697e2eSGuillaume Nault 	mtu = l2tp_tunnel_dst_mtu(tunnel) - overhead;
239e9697e2eSGuillaume Nault 	if (mtu < dev->min_mtu || mtu > dev->max_mtu)
240e9697e2eSGuillaume Nault 		dev->mtu = ETH_DATA_LEN - overhead;
241e9697e2eSGuillaume Nault 	else
2421f5cd2a0SGuillaume Nault 		dev->mtu = mtu;
243e9697e2eSGuillaume Nault 
244b784e7ebSR. Parameswaran 	dev->needed_headroom += session->hdr_len;
245b784e7ebSR. Parameswaran }
246b784e7ebSR. Parameswaran 
l2tp_eth_create(struct net * net,struct l2tp_tunnel * tunnel,u32 session_id,u32 peer_session_id,struct l2tp_session_cfg * cfg)247f026bc29SGuillaume Nault static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
248f026bc29SGuillaume Nault 			   u32 session_id, u32 peer_session_id,
249f026bc29SGuillaume Nault 			   struct l2tp_session_cfg *cfg)
250d9e31d17SJames Chapman {
251c39855feSGuillaume Nault 	unsigned char name_assign_type;
252d9e31d17SJames Chapman 	struct net_device *dev;
253d9e31d17SJames Chapman 	char name[IFNAMSIZ];
254d9e31d17SJames Chapman 	struct l2tp_session *session;
255d9e31d17SJames Chapman 	struct l2tp_eth *priv;
256d9e31d17SJames Chapman 	struct l2tp_eth_sess *spriv;
257d9e31d17SJames Chapman 	int rc;
258d9e31d17SJames Chapman 
259d9e31d17SJames Chapman 	if (cfg->ifname) {
260a5afe530SWolfram Sang 		strscpy(name, cfg->ifname, IFNAMSIZ);
261c39855feSGuillaume Nault 		name_assign_type = NET_NAME_USER;
262c39855feSGuillaume Nault 	} else {
263d9e31d17SJames Chapman 		strcpy(name, L2TP_ETH_DEV_NAME);
264c39855feSGuillaume Nault 		name_assign_type = NET_NAME_ENUM;
265c39855feSGuillaume Nault 	}
266d9e31d17SJames Chapman 
267d9e31d17SJames Chapman 	session = l2tp_session_create(sizeof(*spriv), tunnel, session_id,
268d9e31d17SJames Chapman 				      peer_session_id, cfg);
269dbdbc73bSGuillaume Nault 	if (IS_ERR(session)) {
270dbdbc73bSGuillaume Nault 		rc = PTR_ERR(session);
271ee28de6bSGuillaume Nault 		goto err;
2723953ae7bSGuillaume Nault 	}
2733953ae7bSGuillaume Nault 
274c39855feSGuillaume Nault 	dev = alloc_netdev(sizeof(*priv), name, name_assign_type,
275c835a677STom Gundersen 			   l2tp_eth_dev_setup);
276d9e31d17SJames Chapman 	if (!dev) {
277d9e31d17SJames Chapman 		rc = -ENOMEM;
278ee28de6bSGuillaume Nault 		goto err_sess;
279d9e31d17SJames Chapman 	}
280d9e31d17SJames Chapman 
281d9e31d17SJames Chapman 	dev_net_set(dev, net);
2828b1efc0fSJarod Wilson 	dev->min_mtu = 0;
2838b1efc0fSJarod Wilson 	dev->max_mtu = ETH_MAX_MTU;
284b784e7ebSR. Parameswaran 	l2tp_eth_adjust_mtu(tunnel, session, dev);
285d9e31d17SJames Chapman 
286d9e31d17SJames Chapman 	priv = netdev_priv(dev);
287d9e31d17SJames Chapman 	priv->session = session;
288d9e31d17SJames Chapman 
289d9e31d17SJames Chapman 	session->recv_skb = l2tp_eth_dev_recv;
290d9e31d17SJames Chapman 	session->session_close = l2tp_eth_delete;
291c2ebc256SArnd Bergmann 	if (IS_ENABLED(CONFIG_L2TP_DEBUGFS))
2920ad66140SJames Chapman 		session->show = l2tp_eth_show;
293d9e31d17SJames Chapman 
294d9e31d17SJames Chapman 	spriv = l2tp_session_priv(session);
295d9e31d17SJames Chapman 
296ee28de6bSGuillaume Nault 	l2tp_session_inc_refcount(session);
297d9e31d17SJames Chapman 
298ee28de6bSGuillaume Nault 	rtnl_lock();
299ee28de6bSGuillaume Nault 
300ee28de6bSGuillaume Nault 	/* Register both device and session while holding the rtnl lock. This
301ee28de6bSGuillaume Nault 	 * ensures that l2tp_eth_delete() will see that there's a device to
302ee28de6bSGuillaume Nault 	 * unregister, even if it happened to run before we assign spriv->dev.
303ee28de6bSGuillaume Nault 	 */
304ee28de6bSGuillaume Nault 	rc = l2tp_session_register(session, tunnel);
305ee28de6bSGuillaume Nault 	if (rc < 0) {
306ee28de6bSGuillaume Nault 		rtnl_unlock();
307ee28de6bSGuillaume Nault 		goto err_sess_dev;
308ee28de6bSGuillaume Nault 	}
309ee28de6bSGuillaume Nault 
310ee28de6bSGuillaume Nault 	rc = register_netdevice(dev);
311ee28de6bSGuillaume Nault 	if (rc < 0) {
312ee28de6bSGuillaume Nault 		rtnl_unlock();
313ee28de6bSGuillaume Nault 		l2tp_session_delete(session);
314ee28de6bSGuillaume Nault 		l2tp_session_dec_refcount(session);
315ee28de6bSGuillaume Nault 		free_netdev(dev);
316ee28de6bSGuillaume Nault 
317ee28de6bSGuillaume Nault 		return rc;
318ee28de6bSGuillaume Nault 	}
319ee28de6bSGuillaume Nault 
320a5afe530SWolfram Sang 	strscpy(session->ifname, dev->name, IFNAMSIZ);
321ee28de6bSGuillaume Nault 	rcu_assign_pointer(spriv->dev, dev);
322ee28de6bSGuillaume Nault 
323ee28de6bSGuillaume Nault 	rtnl_unlock();
324ee28de6bSGuillaume Nault 
3253953ae7bSGuillaume Nault 	l2tp_session_dec_refcount(session);
326d9e31d17SJames Chapman 
327ee28de6bSGuillaume Nault 	__module_get(THIS_MODULE);
328d9e31d17SJames Chapman 
329d9e31d17SJames Chapman 	return 0;
330d9e31d17SJames Chapman 
331ee28de6bSGuillaume Nault err_sess_dev:
3323953ae7bSGuillaume Nault 	l2tp_session_dec_refcount(session);
333ee28de6bSGuillaume Nault 	free_netdev(dev);
334ee28de6bSGuillaume Nault err_sess:
335ee28de6bSGuillaume Nault 	kfree(session);
336ee28de6bSGuillaume Nault err:
337d9e31d17SJames Chapman 	return rc;
338d9e31d17SJames Chapman }
339d9e31d17SJames Chapman 
340d9e31d17SJames Chapman static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = {
341d9e31d17SJames Chapman 	.session_create	= l2tp_eth_create,
342d9e31d17SJames Chapman 	.session_delete	= l2tp_session_delete,
343d9e31d17SJames Chapman };
344d9e31d17SJames Chapman 
l2tp_eth_init(void)345d9e31d17SJames Chapman static int __init l2tp_eth_init(void)
346d9e31d17SJames Chapman {
347d9e31d17SJames Chapman 	int err = 0;
348d9e31d17SJames Chapman 
349d9e31d17SJames Chapman 	err = l2tp_nl_register_ops(L2TP_PWTYPE_ETH, &l2tp_eth_nl_cmd_ops);
350d9e31d17SJames Chapman 	if (err)
3519f775eadSGuillaume Nault 		goto err;
352d9e31d17SJames Chapman 
353a4ca44faSJoe Perches 	pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
354d9e31d17SJames Chapman 
355d9e31d17SJames Chapman 	return 0;
356d9e31d17SJames Chapman 
3579f775eadSGuillaume Nault err:
358d9e31d17SJames Chapman 	return err;
359d9e31d17SJames Chapman }
360d9e31d17SJames Chapman 
l2tp_eth_exit(void)361d9e31d17SJames Chapman static void __exit l2tp_eth_exit(void)
362d9e31d17SJames Chapman {
363d9e31d17SJames Chapman 	l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH);
364d9e31d17SJames Chapman }
365d9e31d17SJames Chapman 
366d9e31d17SJames Chapman module_init(l2tp_eth_init);
367d9e31d17SJames Chapman module_exit(l2tp_eth_exit);
368d9e31d17SJames Chapman 
369d9e31d17SJames Chapman MODULE_LICENSE("GPL");
370d9e31d17SJames Chapman MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
371d9e31d17SJames Chapman MODULE_DESCRIPTION("L2TP ethernet pseudowire driver");
372d9e31d17SJames Chapman MODULE_VERSION("1.0");
373f1f39f91Sstephen hemminger MODULE_ALIAS_L2TP_PWTYPE(5);
374