diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-06 12:12:20 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-06 12:12:20 +0100 |
commit | 7cc2e9953226d80e1fe20bbf51d5e5fdd00851f4 (patch) | |
tree | 56dc2ef465a1af6c1edb2fe2464fbe42b8c9945d /src/data.c | |
parent | chacha20poly1305: cleanup magic constants (diff) | |
download | wireguard-monolithic-historical-7cc2e9953226d80e1fe20bbf51d5e5fdd00851f4.tar.xz wireguard-monolithic-historical-7cc2e9953226d80e1fe20bbf51d5e5fdd00851f4.zip |
data: we care about per-peer, not per-device, inflight encryptions
Diffstat (limited to 'src/data.c')
-rw-r--r-- | src/data.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); |