From 7cc2e9953226d80e1fe20bbf51d5e5fdd00851f4 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 6 Nov 2016 12:12:20 +0100 Subject: data: we care about per-peer, not per-device, inflight encryptions --- src/data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/data.c') 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); -- cgit v1.2.3-59-g8ed1b