diff options
-rw-r--r-- | src/compat.h | 13 | ||||
-rw-r--r-- | src/data.c | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/compat.h b/src/compat.h index 29bd8c4..68c56e3 100644 --- a/src/compat.h +++ b/src/compat.h @@ -129,4 +129,17 @@ static inline struct net_device *netdev_pub(void *dev) return (struct net_device *)((char *)dev - ALIGN(sizeof(struct net_device), NETDEV_ALIGN)); } +/* https://lkml.org/lkml/2016/10/1/187 */ +#ifdef CONFIG_WIREGUARD_PARALLEL +#include <linux/padata.h> +static inline int padata_queue_len(struct padata_instance *pinst) +{ + int len; + rcu_read_lock_bh(); + len = atomic_read(&rcu_dereference_bh(pinst->pd)->refcnt); + rcu_read_unlock_bh(); + return len; +} +#endif + #endif @@ -234,7 +234,7 @@ int packet_create_data(struct sk_buff *skb, struct wireguard_peer *peer, void(*c ctx->keypair = keypair; #ifdef CONFIG_WIREGUARD_PARALLEL - if (parallel && cpumask_weight(cpu_online_mask) > 1) { + if ((parallel || padata_queue_len(peer->device->parallel_send) > 0) && cpumask_weight(cpu_online_mask) > 1) { unsigned int cpu = choose_cpu(keypair->remote_index); ret = start_encryption(peer->device->parallel_send, &ctx->padata, cpu); if (unlikely(ret < 0)) |