From aad9d7bccd158836918df742896272dad6af2395 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 6 Nov 2016 19:50:48 +0100 Subject: data: only uses kmem_cache for parallism --- src/data.c | 2 ++ src/main.c | 6 ++++++ src/packets.h | 3 +++ 3 files changed, 11 insertions(+) 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) -- cgit v1.2.3-59-g8ed1b