James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * L2TPv3 ethernet pseudowire driver |
| 3 | * |
| 4 | * Copyright (c) 2008,2009,2010 Katalix Systems Ltd |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Joe Perches | a4ca44f | 2012-05-16 09:55:56 +0000 | [diff] [blame] | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 13 | |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/skbuff.h> |
| 16 | #include <linux/socket.h> |
| 17 | #include <linux/hash.h> |
| 18 | #include <linux/l2tp.h> |
| 19 | #include <linux/in.h> |
| 20 | #include <linux/etherdevice.h> |
| 21 | #include <linux/spinlock.h> |
| 22 | #include <net/sock.h> |
| 23 | #include <net/ip.h> |
| 24 | #include <net/icmp.h> |
| 25 | #include <net/udp.h> |
| 26 | #include <net/inet_common.h> |
| 27 | #include <net/inet_hashtables.h> |
| 28 | #include <net/tcp_states.h> |
| 29 | #include <net/protocol.h> |
| 30 | #include <net/xfrm.h> |
| 31 | #include <net/net_namespace.h> |
| 32 | #include <net/netns/generic.h> |
R. Parameswaran | b784e7e | 2017-04-05 17:00:07 -0700 | [diff] [blame] | 33 | #include <linux/ip.h> |
| 34 | #include <linux/ipv6.h> |
| 35 | #include <linux/udp.h> |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 36 | |
| 37 | #include "l2tp_core.h" |
| 38 | |
| 39 | /* Default device name. May be overridden by name specified by user */ |
| 40 | #define L2TP_ETH_DEV_NAME "l2tpeth%d" |
| 41 | |
| 42 | /* via netdev_priv() */ |
| 43 | struct l2tp_eth { |
| 44 | struct net_device *dev; |
| 45 | struct sock *tunnel_sock; |
| 46 | struct l2tp_session *session; |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 47 | atomic_long_t tx_bytes; |
| 48 | atomic_long_t tx_packets; |
Eric Dumazet | b8c8430 | 2012-06-28 20:15:13 +0000 | [diff] [blame] | 49 | atomic_long_t tx_dropped; |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 50 | atomic_long_t rx_bytes; |
| 51 | atomic_long_t rx_packets; |
| 52 | atomic_long_t rx_errors; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | /* via l2tp_session_priv() */ |
| 56 | struct l2tp_eth_sess { |
| 57 | struct net_device *dev; |
| 58 | }; |
| 59 | |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 60 | |
| 61 | static int l2tp_eth_dev_init(struct net_device *dev) |
| 62 | { |
| 63 | struct l2tp_eth *priv = netdev_priv(dev); |
| 64 | |
| 65 | priv->dev = dev; |
Danny Kukawka | f2cedb6 | 2012-02-15 06:45:39 +0000 | [diff] [blame] | 66 | eth_hw_addr_random(dev); |
Joe Perches | 1cea7e2 | 2015-03-02 19:54:59 -0800 | [diff] [blame] | 67 | eth_broadcast_addr(dev->broadcast); |
Eric Dumazet | d3fff6c | 2016-06-09 07:45:12 -0700 | [diff] [blame] | 68 | netdev_lockdep_set_classes(dev); |
Eric Dumazet | f9eb8ae | 2016-06-06 09:37:15 -0700 | [diff] [blame] | 69 | |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static void l2tp_eth_dev_uninit(struct net_device *dev) |
| 74 | { |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 75 | dev_put(dev); |
| 76 | } |
| 77 | |
| 78 | static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev) |
| 79 | { |
| 80 | struct l2tp_eth *priv = netdev_priv(dev); |
| 81 | struct l2tp_session *session = priv->session; |
Eric Dumazet | b8c8430 | 2012-06-28 20:15:13 +0000 | [diff] [blame] | 82 | unsigned int len = skb->len; |
| 83 | int ret = l2tp_xmit_skb(session, skb, session->hdr_len); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 84 | |
WANG Cong | a4cd027 | 2016-11-21 23:24:43 -0800 | [diff] [blame] | 85 | if (likely(ret == NET_XMIT_SUCCESS)) { |
Eric Dumazet | b8c8430 | 2012-06-28 20:15:13 +0000 | [diff] [blame] | 86 | atomic_long_add(len, &priv->tx_bytes); |
| 87 | atomic_long_inc(&priv->tx_packets); |
| 88 | } else { |
| 89 | atomic_long_inc(&priv->tx_dropped); |
| 90 | } |
Eric Dumazet | aa214de0 | 2012-06-25 00:45:14 +0000 | [diff] [blame] | 91 | return NETDEV_TX_OK; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 92 | } |
| 93 | |
stephen hemminger | bc1f447 | 2017-01-06 19:12:52 -0800 | [diff] [blame] | 94 | static void l2tp_eth_get_stats64(struct net_device *dev, |
| 95 | struct rtnl_link_stats64 *stats) |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 96 | { |
| 97 | struct l2tp_eth *priv = netdev_priv(dev); |
| 98 | |
Dominik Heidler | 9b3dc0a | 2017-06-09 16:29:47 +0200 | [diff] [blame] | 99 | stats->tx_bytes = (unsigned long) atomic_long_read(&priv->tx_bytes); |
| 100 | stats->tx_packets = (unsigned long) atomic_long_read(&priv->tx_packets); |
| 101 | stats->tx_dropped = (unsigned long) atomic_long_read(&priv->tx_dropped); |
| 102 | stats->rx_bytes = (unsigned long) atomic_long_read(&priv->rx_bytes); |
| 103 | stats->rx_packets = (unsigned long) atomic_long_read(&priv->rx_packets); |
| 104 | stats->rx_errors = (unsigned long) atomic_long_read(&priv->rx_errors); |
| 105 | |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Julia Lawall | eb94737 | 2016-09-15 22:23:26 +0200 | [diff] [blame] | 108 | static const struct net_device_ops l2tp_eth_netdev_ops = { |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 109 | .ndo_init = l2tp_eth_dev_init, |
| 110 | .ndo_uninit = l2tp_eth_dev_uninit, |
| 111 | .ndo_start_xmit = l2tp_eth_dev_xmit, |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 112 | .ndo_get_stats64 = l2tp_eth_get_stats64, |
Alexander Couzens | fe15912 | 2014-11-19 13:24:39 +0100 | [diff] [blame] | 113 | .ndo_set_mac_address = eth_mac_addr, |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 114 | }; |
| 115 | |
Guillaume Nault | a485c2b | 2017-04-24 14:16:07 +0200 | [diff] [blame] | 116 | static struct device_type l2tpeth_type = { |
| 117 | .name = "l2tpeth", |
| 118 | }; |
| 119 | |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 120 | static void l2tp_eth_dev_setup(struct net_device *dev) |
| 121 | { |
Guillaume Nault | a485c2b | 2017-04-24 14:16:07 +0200 | [diff] [blame] | 122 | SET_NETDEV_DEVTYPE(dev, &l2tpeth_type); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 123 | ether_setup(dev); |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 124 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 125 | dev->features |= NETIF_F_LLTX; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 126 | dev->netdev_ops = &l2tp_eth_netdev_ops; |
David S. Miller | cf124db | 2017-05-08 12:52:56 -0400 | [diff] [blame] | 127 | dev->needs_free_netdev = true; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len) |
| 131 | { |
| 132 | struct l2tp_eth_sess *spriv = l2tp_session_priv(session); |
| 133 | struct net_device *dev = spriv->dev; |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 134 | struct l2tp_eth *priv = netdev_priv(dev); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 135 | |
| 136 | if (session->debug & L2TP_MSG_DATA) { |
| 137 | unsigned int length; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 138 | |
| 139 | length = min(32u, skb->len); |
| 140 | if (!pskb_may_pull(skb, length)) |
| 141 | goto error; |
| 142 | |
Joe Perches | a4ca44f | 2012-05-16 09:55:56 +0000 | [diff] [blame] | 143 | pr_debug("%s: eth recv\n", session->name); |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 144 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Eric Dumazet | c0cc88a | 2012-09-04 15:54:55 -0400 | [diff] [blame] | 147 | if (!pskb_may_pull(skb, ETH_HLEN)) |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 148 | goto error; |
| 149 | |
| 150 | secpath_reset(skb); |
| 151 | |
| 152 | /* checksums verified by L2TP */ |
| 153 | skb->ip_summed = CHECKSUM_NONE; |
| 154 | |
| 155 | skb_dst_drop(skb); |
| 156 | nf_reset(skb); |
| 157 | |
| 158 | if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) { |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 159 | atomic_long_inc(&priv->rx_packets); |
| 160 | atomic_long_add(data_len, &priv->rx_bytes); |
| 161 | } else { |
| 162 | atomic_long_inc(&priv->rx_errors); |
| 163 | } |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 164 | return; |
| 165 | |
| 166 | error: |
Eric Dumazet | a2842a1 | 2012-06-25 05:35:45 +0000 | [diff] [blame] | 167 | atomic_long_inc(&priv->rx_errors); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 168 | kfree_skb(skb); |
| 169 | } |
| 170 | |
| 171 | static void l2tp_eth_delete(struct l2tp_session *session) |
| 172 | { |
| 173 | struct l2tp_eth_sess *spriv; |
| 174 | struct net_device *dev; |
| 175 | |
| 176 | if (session) { |
| 177 | spriv = l2tp_session_priv(session); |
| 178 | dev = spriv->dev; |
| 179 | if (dev) { |
| 180 | unregister_netdev(dev); |
| 181 | spriv->dev = NULL; |
Eric Dumazet | a06998b | 2012-06-07 00:07:20 +0000 | [diff] [blame] | 182 | module_put(THIS_MODULE); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
Javier Martinez Canillas | 9dd7994 | 2016-09-09 08:43:17 -0400 | [diff] [blame] | 187 | #if IS_ENABLED(CONFIG_L2TP_DEBUGFS) |
James Chapman | 0ad6614 | 2010-04-02 06:19:33 +0000 | [diff] [blame] | 188 | static void l2tp_eth_show(struct seq_file *m, void *arg) |
| 189 | { |
| 190 | struct l2tp_session *session = arg; |
| 191 | struct l2tp_eth_sess *spriv = l2tp_session_priv(session); |
| 192 | struct net_device *dev = spriv->dev; |
| 193 | |
| 194 | seq_printf(m, " interface %s\n", dev->name); |
| 195 | } |
| 196 | #endif |
| 197 | |
R. Parameswaran | b784e7e | 2017-04-05 17:00:07 -0700 | [diff] [blame] | 198 | static void l2tp_eth_adjust_mtu(struct l2tp_tunnel *tunnel, |
| 199 | struct l2tp_session *session, |
| 200 | struct net_device *dev) |
| 201 | { |
| 202 | unsigned int overhead = 0; |
| 203 | struct dst_entry *dst; |
| 204 | u32 l3_overhead = 0; |
| 205 | |
| 206 | /* if the encap is UDP, account for UDP header size */ |
| 207 | if (tunnel->encap == L2TP_ENCAPTYPE_UDP) { |
| 208 | overhead += sizeof(struct udphdr); |
| 209 | dev->needed_headroom += sizeof(struct udphdr); |
| 210 | } |
| 211 | if (session->mtu != 0) { |
| 212 | dev->mtu = session->mtu; |
| 213 | dev->needed_headroom += session->hdr_len; |
| 214 | return; |
| 215 | } |
R. Parameswaran | 57240d0 | 2017-04-12 18:31:04 -0700 | [diff] [blame] | 216 | lock_sock(tunnel->sock); |
R. Parameswaran | b784e7e | 2017-04-05 17:00:07 -0700 | [diff] [blame] | 217 | l3_overhead = kernel_sock_ip_overhead(tunnel->sock); |
R. Parameswaran | 57240d0 | 2017-04-12 18:31:04 -0700 | [diff] [blame] | 218 | release_sock(tunnel->sock); |
R. Parameswaran | b784e7e | 2017-04-05 17:00:07 -0700 | [diff] [blame] | 219 | if (l3_overhead == 0) { |
| 220 | /* L3 Overhead couldn't be identified, this could be |
| 221 | * because tunnel->sock was NULL or the socket's |
| 222 | * address family was not IPv4 or IPv6, |
| 223 | * dev mtu stays at 1500. |
| 224 | */ |
| 225 | return; |
| 226 | } |
| 227 | /* Adjust MTU, factor overhead - underlay L3, overlay L2 hdr |
| 228 | * UDP overhead, if any, was already factored in above. |
| 229 | */ |
| 230 | overhead += session->hdr_len + ETH_HLEN + l3_overhead; |
| 231 | |
| 232 | /* If PMTU discovery was enabled, use discovered MTU on L2TP device */ |
| 233 | dst = sk_dst_get(tunnel->sock); |
| 234 | if (dst) { |
| 235 | /* dst_mtu will use PMTU if found, else fallback to intf MTU */ |
| 236 | u32 pmtu = dst_mtu(dst); |
| 237 | |
| 238 | if (pmtu != 0) |
| 239 | dev->mtu = pmtu; |
| 240 | dst_release(dst); |
| 241 | } |
| 242 | session->mtu = dev->mtu - overhead; |
| 243 | dev->mtu = session->mtu; |
| 244 | dev->needed_headroom += session->hdr_len; |
| 245 | } |
| 246 | |
Guillaume Nault | f026bc2 | 2017-09-01 17:58:51 +0200 | [diff] [blame] | 247 | static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel, |
| 248 | u32 session_id, u32 peer_session_id, |
| 249 | struct l2tp_session_cfg *cfg) |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 250 | { |
Guillaume Nault | c39855f | 2017-04-24 14:16:06 +0200 | [diff] [blame] | 251 | unsigned char name_assign_type; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 252 | struct net_device *dev; |
| 253 | char name[IFNAMSIZ]; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 254 | struct l2tp_session *session; |
| 255 | struct l2tp_eth *priv; |
| 256 | struct l2tp_eth_sess *spriv; |
| 257 | int rc; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 258 | |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 259 | if (cfg->ifname) { |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 260 | strlcpy(name, cfg->ifname, IFNAMSIZ); |
Guillaume Nault | c39855f | 2017-04-24 14:16:06 +0200 | [diff] [blame] | 261 | name_assign_type = NET_NAME_USER; |
| 262 | } else { |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 263 | strcpy(name, L2TP_ETH_DEV_NAME); |
Guillaume Nault | c39855f | 2017-04-24 14:16:06 +0200 | [diff] [blame] | 264 | name_assign_type = NET_NAME_ENUM; |
| 265 | } |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 266 | |
| 267 | session = l2tp_session_create(sizeof(*spriv), tunnel, session_id, |
| 268 | peer_session_id, cfg); |
Guillaume Nault | dbdbc73 | 2017-03-31 13:02:27 +0200 | [diff] [blame] | 269 | if (IS_ERR(session)) { |
| 270 | rc = PTR_ERR(session); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 271 | goto out; |
| 272 | } |
| 273 | |
Guillaume Nault | 3953ae7 | 2017-10-27 16:51:50 +0200 | [diff] [blame^] | 274 | l2tp_session_inc_refcount(session); |
| 275 | rc = l2tp_session_register(session, tunnel); |
| 276 | if (rc < 0) { |
| 277 | kfree(session); |
| 278 | goto out; |
| 279 | } |
| 280 | |
Guillaume Nault | c39855f | 2017-04-24 14:16:06 +0200 | [diff] [blame] | 281 | dev = alloc_netdev(sizeof(*priv), name, name_assign_type, |
Tom Gundersen | c835a67 | 2014-07-14 16:37:24 +0200 | [diff] [blame] | 282 | l2tp_eth_dev_setup); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 283 | if (!dev) { |
| 284 | rc = -ENOMEM; |
| 285 | goto out_del_session; |
| 286 | } |
| 287 | |
| 288 | dev_net_set(dev, net); |
Jarod Wilson | 8b1efc0 | 2016-10-20 23:25:27 -0400 | [diff] [blame] | 289 | dev->min_mtu = 0; |
| 290 | dev->max_mtu = ETH_MAX_MTU; |
R. Parameswaran | b784e7e | 2017-04-05 17:00:07 -0700 | [diff] [blame] | 291 | l2tp_eth_adjust_mtu(tunnel, session, dev); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 292 | |
| 293 | priv = netdev_priv(dev); |
| 294 | priv->dev = dev; |
| 295 | priv->session = session; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 296 | |
| 297 | priv->tunnel_sock = tunnel->sock; |
| 298 | session->recv_skb = l2tp_eth_dev_recv; |
| 299 | session->session_close = l2tp_eth_delete; |
Javier Martinez Canillas | 9dd7994 | 2016-09-09 08:43:17 -0400 | [diff] [blame] | 300 | #if IS_ENABLED(CONFIG_L2TP_DEBUGFS) |
James Chapman | 0ad6614 | 2010-04-02 06:19:33 +0000 | [diff] [blame] | 301 | session->show = l2tp_eth_show; |
| 302 | #endif |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 303 | |
| 304 | spriv = l2tp_session_priv(session); |
| 305 | spriv->dev = dev; |
| 306 | |
| 307 | rc = register_netdev(dev); |
| 308 | if (rc < 0) |
| 309 | goto out_del_dev; |
| 310 | |
Eric Dumazet | a06998b | 2012-06-07 00:07:20 +0000 | [diff] [blame] | 311 | __module_get(THIS_MODULE); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 312 | /* Must be done after register_netdev() */ |
| 313 | strlcpy(session->ifname, dev->name, IFNAMSIZ); |
Guillaume Nault | 3953ae7 | 2017-10-27 16:51:50 +0200 | [diff] [blame^] | 314 | l2tp_session_dec_refcount(session); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 315 | |
| 316 | dev_hold(dev); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 317 | |
| 318 | return 0; |
| 319 | |
| 320 | out_del_dev: |
| 321 | free_netdev(dev); |
Tom Parkin | 7893363 | 2012-10-29 23:41:48 +0000 | [diff] [blame] | 322 | spriv->dev = NULL; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 323 | out_del_session: |
| 324 | l2tp_session_delete(session); |
Guillaume Nault | 3953ae7 | 2017-10-27 16:51:50 +0200 | [diff] [blame^] | 325 | l2tp_session_dec_refcount(session); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 326 | out: |
| 327 | return rc; |
| 328 | } |
| 329 | |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 330 | |
| 331 | static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = { |
| 332 | .session_create = l2tp_eth_create, |
| 333 | .session_delete = l2tp_session_delete, |
| 334 | }; |
| 335 | |
| 336 | |
| 337 | static int __init l2tp_eth_init(void) |
| 338 | { |
| 339 | int err = 0; |
| 340 | |
| 341 | err = l2tp_nl_register_ops(L2TP_PWTYPE_ETH, &l2tp_eth_nl_cmd_ops); |
| 342 | if (err) |
Guillaume Nault | 9f775ea | 2017-09-28 15:44:38 +0200 | [diff] [blame] | 343 | goto err; |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 344 | |
Joe Perches | a4ca44f | 2012-05-16 09:55:56 +0000 | [diff] [blame] | 345 | pr_info("L2TP ethernet pseudowire support (L2TPv3)\n"); |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 346 | |
| 347 | return 0; |
| 348 | |
Guillaume Nault | 9f775ea | 2017-09-28 15:44:38 +0200 | [diff] [blame] | 349 | err: |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 350 | return err; |
| 351 | } |
| 352 | |
| 353 | static void __exit l2tp_eth_exit(void) |
| 354 | { |
James Chapman | d9e31d1 | 2010-04-02 06:19:26 +0000 | [diff] [blame] | 355 | l2tp_nl_unregister_ops(L2TP_PWTYPE_ETH); |
| 356 | } |
| 357 | |
| 358 | module_init(l2tp_eth_init); |
| 359 | module_exit(l2tp_eth_exit); |
| 360 | |
| 361 | MODULE_LICENSE("GPL"); |
| 362 | MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); |
| 363 | MODULE_DESCRIPTION("L2TP ethernet pseudowire driver"); |
| 364 | MODULE_VERSION("1.0"); |
stephen hemminger | f1f39f9 | 2015-09-23 21:33:34 -0700 | [diff] [blame] | 365 | MODULE_ALIAS_L2TP_PWTYPE(5); |