diff options
author | Gabriel Oginski <gabrielx.oginski@intel.com> | 2021-10-08 09:09:45 +0100 |
---|---|---|
committer | Matthew Smith <mgsmith@netgate.com> | 2021-11-03 16:04:00 +0000 |
commit | 4739c8833e2e8013417ef0e52610d8b310e97a93 (patch) | |
tree | dbcc0c49dbeacad72005ef58c22d0e4ab13c2250 /src/plugins/wireguard/wireguard_noise.c | |
parent | 505fd37b31aa5a7d242184ebe281dbd4622ad277 (diff) |
wireguard: reduce memcopy and prefetch header
Originally wireguard implementation does memory copy of the whole
packet in encryption and decryption.
This patch removes unnecessary packet copy in wireguard. In addition,
it contains some performance improvement such as prefetching header
and deleting unnecessary lock and unlock for decryption.
Type: improvement
Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com>
Change-Id: I1fe8e54d749e6922465341083b448c842e2b670f
Diffstat (limited to 'src/plugins/wireguard/wireguard_noise.c')
-rw-r--r-- | src/plugins/wireguard/wireguard_noise.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/src/plugins/wireguard/wireguard_noise.c b/src/plugins/wireguard/wireguard_noise.c index 7b4c01942bc..36de8ae9cac 100644 --- a/src/plugins/wireguard/wireguard_noise.c +++ b/src/plugins/wireguard/wireguard_noise.c @@ -549,7 +549,6 @@ noise_remote_encrypt (vlib_main_t * vm, noise_remote_t * r, uint32_t * r_idx, noise_keypair_t *kp; enum noise_state_crypt ret = SC_FAILED; - clib_rwlock_reader_lock (&r->r_keypair_lock); if ((kp = r->r_current) == NULL) goto error; @@ -589,7 +588,6 @@ noise_remote_encrypt (vlib_main_t * vm, noise_remote_t * r, uint32_t * r_idx, ret = SC_OK; error: - clib_rwlock_reader_unlock (&r->r_keypair_lock); return ret; } @@ -600,7 +598,6 @@ noise_remote_decrypt (vlib_main_t * vm, noise_remote_t * r, uint32_t r_idx, { noise_keypair_t *kp; enum noise_state_crypt ret = SC_FAILED; - clib_rwlock_reader_lock (&r->r_keypair_lock); if (r->r_current != NULL && r->r_current->kp_local_index == r_idx) { @@ -644,7 +641,6 @@ noise_remote_decrypt (vlib_main_t * vm, noise_remote_t * r, uint32_t r_idx, * data packet can't confirm a session that we are an INITIATOR of. */ if (kp == r->r_next) { - clib_rwlock_reader_unlock (&r->r_keypair_lock); clib_rwlock_writer_lock (&r->r_keypair_lock); if (kp == r->r_next && kp->kp_local_index == r_idx) { @@ -655,11 +651,9 @@ noise_remote_decrypt (vlib_main_t * vm, noise_remote_t * r, uint32_t r_idx, ret = SC_CONN_RESET; clib_rwlock_writer_unlock (&r->r_keypair_lock); - clib_rwlock_reader_lock (&r->r_keypair_lock); goto error; } clib_rwlock_writer_unlock (&r->r_keypair_lock); - clib_rwlock_reader_lock (&r->r_keypair_lock); } /* Similar to when we encrypt, we want to notify the caller when we @@ -676,7 +670,6 @@ noise_remote_decrypt (vlib_main_t * vm, noise_remote_t * r, uint32_t r_idx, ret = SC_OK; error: - clib_rwlock_reader_unlock (&r->r_keypair_lock); return ret; } |