aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/send.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
commit5856479cdaf7e87f2bc46881246607ec3b887dae (patch)
treebfff84bd6d34cfefa014681629b55a5081d0ed54 /src/send.c
parentcompat: better atomic acquire/release backport (diff)
downloadwireguard-monolithic-historical-5856479cdaf7e87f2bc46881246607ec3b887dae.tar.xz
wireguard-monolithic-historical-5856479cdaf7e87f2bc46881246607ec3b887dae.zip
crypto: move simd context to specific type
Suggested-by: Andy Lutomirski <luto@kernel.org>
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/send.c b/src/send.c
index 3fc2a17..3af7ef3 100644
--- a/src/send.c
+++ b/src/send.c
@@ -126,7 +126,7 @@ static inline unsigned int skb_padding(struct sk_buff *skb)
return padded_size - last_unit;
}
-static inline bool skb_encrypt(struct sk_buff *skb, struct noise_keypair *keypair, bool have_simd)
+static inline bool skb_encrypt(struct sk_buff *skb, struct noise_keypair *keypair, simd_context_t simd_context)
{
struct scatterlist sg[MAX_SKB_FRAGS * 2 + 1];
struct message_data *header;
@@ -167,7 +167,7 @@ static inline bool skb_encrypt(struct sk_buff *skb, struct noise_keypair *keypai
sg_init_table(sg, num_frags);
if (skb_to_sgvec(skb, sg, sizeof(struct message_data), noise_encrypted_len(plaintext_len)) <= 0)
return false;
- return chacha20poly1305_encrypt_sg(sg, sg, plaintext_len, NULL, 0, PACKET_CB(skb)->nonce, keypair->sending.key, have_simd);
+ return chacha20poly1305_encrypt_sg(sg, sg, plaintext_len, NULL, 0, PACKET_CB(skb)->nonce, keypair->sending.key, simd_context);
}
void packet_send_keepalive(struct wireguard_peer *peer)
@@ -243,13 +243,13 @@ void packet_encrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct sk_buff *first, *skb, *next;
- bool have_simd = simd_get();
+ simd_context_t simd_context = simd_get();
while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state = PACKET_STATE_CRYPTED;
skb_walk_null_queue_safe(first, skb, next) {
- if (likely(skb_encrypt(skb, PACKET_CB(first)->keypair, have_simd)))
+ if (likely(skb_encrypt(skb, PACKET_CB(first)->keypair, simd_context)))
skb_reset(skb);
else {
state = PACKET_STATE_DEAD;
@@ -258,9 +258,9 @@ void packet_encrypt_worker(struct work_struct *work)
}
queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first, state);
- have_simd = simd_relax(have_simd);
+ simd_context = simd_relax(simd_context);
}
- simd_put(have_simd);
+ simd_put(simd_context);
}
static void packet_create_data(struct sk_buff *first)