summaryrefslogtreecommitdiffstatshomepage
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 3102408..cd8c591 100644
--- a/src/main.c
+++ b/src/main.c
@@ -16,7 +16,7 @@
static int __init mod_init(void)
{
- int ret = 0;
+ int ret;
#ifdef DEBUG
if (!routing_table_selftest() ||
@@ -30,22 +30,31 @@ static int __init mod_init(void)
chacha20poly1305_init();
noise_init();
+ ret = ratelimiter_module_init();
+ if (ret < 0)
+ goto out;
+
#ifdef CONFIG_WIREGUARD_PARALLEL
ret = packet_init_data_caches();
if (ret < 0)
- return ret;
+ goto err_packet;
#endif
ret = device_init();
- if (ret < 0) {
-#ifdef CONFIG_WIREGUARD_PARALLEL
- packet_deinit_data_caches();
-#endif
- return ret;
- }
+ if (ret < 0)
+ goto err_device;
pr_info("WireGuard " WIREGUARD_VERSION " loaded. See www.wireguard.io for information.\n");
pr_info("Copyright (C) 2015-2016 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.\n");
+
+ goto out;
+err_device:
+#ifdef CONFIG_WIREGUARD_PARALLEL
+ packet_deinit_data_caches();
+#endif
+err_packet:
+ ratelimiter_module_deinit();
+out:
return ret;
}
@@ -55,6 +64,7 @@ static void __exit mod_exit(void)
#ifdef CONFIG_WIREGUARD_PARALLEL
packet_deinit_data_caches();
#endif
+ ratelimiter_module_deinit();
pr_debug("WireGuard has been unloaded\n");
}