summaryrefslogtreecommitdiffhomepage
path: root/src/data.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-06 12:12:20 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-06 12:12:20 +0100
commit6e96d730778ede3be025d0badc7af7478bd988a1 (patch)
treeb34cc5884850ae7f48823fca6d77810481745f9d /src/data.c
parent4d507da21c4ebde37efd85c5cc727fab26f5404a (diff)
data: we care about per-peer, not per-device, inflight encryptions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/data.c b/src/data.c
index e027510..a3ed739 100644
--- a/src/data.c
+++ b/src/data.c
@@ -215,6 +215,7 @@ static void finish_encryption(struct padata_priv *padata)
struct encryption_ctx *ctx = container_of(padata, struct encryption_ctx, padata);
ctx->callback(&ctx->queue, ctx->peer);
+ atomic_dec(&ctx->peer->parallel_encryption_inflight);
peer_put(ctx->peer);
kmem_cache_free(encryption_ctx_cache, ctx);
}
@@ -295,7 +296,7 @@ int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer,
}
#ifdef CONFIG_WIREGUARD_PARALLEL
- if ((skb_queue_len(queue) > 1 || queue->next->len > 256 || padata_queue_len(peer->device->parallel_send) > 0) && cpumask_weight(cpu_online_mask) > 1) {
+ if ((skb_queue_len(queue) > 1 || queue->next->len > 256 || atomic_read(&peer->parallel_encryption_inflight) > 0) && cpumask_weight(cpu_online_mask) > 1) {
unsigned int cpu = choose_cpu(keypair->remote_index);
struct encryption_ctx *ctx = kmem_cache_alloc(encryption_ctx_cache, GFP_ATOMIC);
if (!ctx)
@@ -308,8 +309,10 @@ int packet_create_data(struct sk_buff_head *queue, struct wireguard_peer *peer,
ret = -EBUSY;
if (unlikely(!ctx->peer))
goto err_parallel;
+ atomic_inc(&peer->parallel_encryption_inflight);
ret = start_encryption(peer->device->parallel_send, &ctx->padata, cpu);
if (unlikely(ret < 0)) {
+ atomic_dec(&peer->parallel_encryption_inflight);
peer_put(ctx->peer);
err_parallel:
skb_queue_splice(&ctx->queue, queue);