summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-06 19:50:48 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-06 19:50:48 +0100
commit8ab6f188f5dff1e173a85d05f443622029b5ac37 (patch)
tree480536629543804b082c1f8b87ca8c2d8753c857
parent468424d08834cac9a5b494dc88048da1af110af3 (diff)
data: only uses kmem_cache for parallism
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/data.c2
-rw-r--r--src/main.c6
-rw-r--r--src/packets.h3
3 files changed, 11 insertions, 0 deletions
diff --git a/src/data.c b/src/data.c
index ab775a5..f53bbc6 100644
--- a/src/data.c
+++ b/src/data.c
@@ -42,6 +42,7 @@ struct decryption_ctx {
int ret;
};
+#ifdef CONFIG_WIREGUARD_PARALLEL
static struct kmem_cache *encryption_ctx_cache;
static struct kmem_cache *decryption_ctx_cache;
@@ -64,6 +65,7 @@ void packet_deinit_data_caches(void)
kmem_cache_destroy(encryption_ctx_cache);
kmem_cache_destroy(decryption_ctx_cache);
}
+#endif
/* This is RFC6479, a replay detection bitmap algorithm that avoids bitshifts */
static inline bool counter_validate(union noise_counter *counter, u64 their_counter)
diff --git a/src/main.c b/src/main.c
index e381d09..e4787ac 100644
--- a/src/main.c
+++ b/src/main.c
@@ -29,13 +29,17 @@ static int __init mod_init(void)
chacha20poly1305_init();
noise_init();
+#ifdef CONFIG_WIREGUARD_PARALLEL
ret = packet_init_data_caches();
if (ret < 0)
return ret;
+#endif
ret = device_init();
if (ret < 0) {
+#ifdef CONFIG_WIREGUARD_PARALLEL
packet_deinit_data_caches();
+#endif
return ret;
}
@@ -47,7 +51,9 @@ static int __init mod_init(void)
static void __exit mod_exit(void)
{
device_uninit();
+#ifdef CONFIG_WIREGUARD_PARALLEL
packet_deinit_data_caches();
+#endif
pr_debug("WireGuard has been unloaded\n");
}
diff --git a/src/packets.h b/src/packets.h
index c9d82d1..03ba891 100644
--- a/src/packets.h
+++ b/src/packets.h
@@ -41,8 +41,11 @@ void packet_send_queued_handshakes(struct work_struct *work);
/* data.c */
int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer, void(*callback)(struct sk_buff_head *, struct wireguard_peer *));
void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, void(*callback)(struct sk_buff *, struct wireguard_peer *, struct sockaddr_storage *, bool used_new_key, int err));
+
+#ifdef CONFIG_WIREGUARD_PARALLEL
int packet_init_data_caches(void);
void packet_deinit_data_caches(void);
+#endif
#define DATA_PACKET_HEAD_ROOM ALIGN(sizeof(struct message_data) + SKB_HEADER_LEN, 4)