diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-06-16 14:47:51 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-06-24 02:06:26 +0200 |
commit | a9cfe4ad0ff4a1d409f8ab23aaeabe7d5bcae660 (patch) | |
tree | 1d5ee5531206c3c5e9b378a544f1128e7d096d19 /src | |
parent | 876a0ac564b79f7e9e86632f317bfd22c86baf23 (diff) |
device: netdevice destruction logic change for 4.12
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/device.c b/src/device.c index d5e3e94..88c7e7a 100644 --- a/src/device.c +++ b/src/device.c @@ -199,7 +199,6 @@ err: return ret; } - static int ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct wireguard_device *wg = netdev_priv(dev); @@ -252,7 +251,9 @@ static void destruct(struct net_device *dev) put_net(wg->creating_net); pr_debug("%s: Interface deleted\n", dev->name); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) free_netdev(dev); +#endif } static void setup(struct net_device *dev) @@ -261,7 +262,12 @@ static void setup(struct net_device *dev) enum { WG_NETDEV_FEATURES = NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO | NETIF_F_GSO_SOFTWARE | NETIF_F_HIGHDMA }; dev->netdev_ops = &netdev_ops; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) dev->destructor = destruct; +#else + dev->priv_destructor = destruct; + dev->needs_free_netdev = true; +#endif dev->hard_header_len = 0; dev->addr_len = 0; dev->needed_headroom = DATA_PACKET_HEAD_ROOM; @@ -349,14 +355,17 @@ static int newlink(struct net *src_net, struct net_device *dev, struct nlattr *t #endif ret = register_netdevice(dev); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) if (ret < 0) goto error_10; - +#endif pr_debug("%s: Interface created\n", dev->name); + return ret; - return 0; - +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) error_10: +#endif #ifdef CONFIG_PM_SLEEP unregister_pm_notifier(&wg->clear_peers_on_suspend); error_9: |