1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 4 */ 5 6 #include "version.h" 7 #include "device.h" 8 #include "noise.h" 9 #include "queueing.h" 10 #include "ratelimiter.h" 11 #include "netlink.h" 12 13 #include <uapi/linux/wireguard.h> 14 15 #include <linux/init.h> 16 #include <linux/module.h> 17 #include <linux/genetlink.h> 18 #include <net/rtnetlink.h> 19 20 static int __init mod_init(void) 21 { 22 int ret; 23 24 #ifdef DEBUG 25 if (!wg_allowedips_selftest() || !wg_packet_counter_selftest() || 26 !wg_ratelimiter_selftest()) 27 return -ENOTRECOVERABLE; 28 #endif 29 wg_noise_init(); 30 31 ret = wg_device_init(); 32 if (ret < 0) 33 goto err_device; 34 35 ret = wg_genetlink_init(); 36 if (ret < 0) 37 goto err_netlink; 38 39 pr_info("WireGuard " WIREGUARD_VERSION " loaded. See www.wireguard.com for information.\n"); 40 pr_info("Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.\n"); 41 42 return 0; 43 44 err_netlink: 45 wg_device_uninit(); 46 err_device: 47 return ret; 48 } 49 50 static void __exit mod_exit(void) 51 { 52 wg_genetlink_uninit(); 53 wg_device_uninit(); 54 } 55 56 module_init(mod_init); 57 module_exit(mod_exit); 58 MODULE_LICENSE("GPL v2"); 59 MODULE_DESCRIPTION("WireGuard secure network tunnel"); 60 MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>"); 61 MODULE_VERSION(WIREGUARD_VERSION); 62 MODULE_ALIAS_RTNL_LINK(KBUILD_MODNAME); 63 MODULE_ALIAS_GENL_FAMILY(WG_GENL_NAME); 64