aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/receive.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-06 18:31:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-06 19:25:29 +0200
commit1a72c38631b775529ba63aeec1f35df7080be609 (patch)
tree3377c9e1fbe00dbd45d90d2eb22dc524443b816d /src/receive.c
parentcompat: better atomic acquire/release backport (diff)
downloadwireguard-linux-compat-1a72c38631b775529ba63aeec1f35df7080be609.tar.xz
wireguard-linux-compat-1a72c38631b775529ba63aeec1f35df7080be609.zip
crypto: move simd context to specific type
Suggested-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/receive.c')
-rw-r--r--src/receive.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/receive.c b/src/receive.c
index d3a698a..4e73da1 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -200,7 +200,7 @@ static inline void keep_key_fresh(struct wireguard_peer *peer)
}
}
-static inline bool skb_decrypt(struct sk_buff *skb, struct noise_symmetric_key *key, bool have_simd)
+static inline bool skb_decrypt(struct sk_buff *skb, struct noise_symmetric_key *key, simd_context_t simd_context)
{
struct scatterlist sg[MAX_SKB_FRAGS * 2 + 1];
struct sk_buff *trailer;
@@ -233,7 +233,7 @@ static inline bool skb_decrypt(struct sk_buff *skb, struct noise_symmetric_key *
if (skb_to_sgvec(skb, sg, 0, skb->len) <= 0)
return false;
- if (!chacha20poly1305_decrypt_sg(sg, sg, skb->len, NULL, 0, PACKET_CB(skb)->nonce, key->key, have_simd))
+ if (!chacha20poly1305_decrypt_sg(sg, sg, skb->len, NULL, 0, PACKET_CB(skb)->nonce, key->key, simd_context))
return false;
/* Another ugly situation of pushing and pulling the header so as to
@@ -423,15 +423,15 @@ void packet_decrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct sk_buff *skb;
- bool have_simd = simd_get();
+ simd_context_t simd_context = simd_get();
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
- enum packet_state state = likely(skb_decrypt(skb, &PACKET_CB(skb)->keypair->receiving, have_simd)) ? PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
+ enum packet_state state = likely(skb_decrypt(skb, &PACKET_CB(skb)->keypair->receiving, simd_context)) ? PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
queue_enqueue_per_peer_napi(&PACKET_PEER(skb)->rx_queue, skb, state);
- have_simd = simd_relax(have_simd);
+ simd_context = simd_relax(simd_context);
}
- simd_put(have_simd);
+ simd_put(simd_context);
}
static void packet_consume_data(struct wireguard_device *wg, struct sk_buff *skb)