diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-12 03:39:10 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-17 19:26:07 +0200 |
commit | 9ad5a4f2bcc3ca0db245679b396563a71df4c49c (patch) | |
tree | 8c12bec4572062a4137f07f6503f91c4bbb5c615 /src/send.c | |
parent | 7a761528abadea4e5c1be8fe8d73c8538f55cdee (diff) |
send: improve dead packet control flow
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -237,20 +237,17 @@ void packet_encrypt_worker(struct work_struct *work) bool have_simd = chacha20poly1305_init_simd(); while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) { - bool dead = false; + 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))) skb_reset(skb); else { - queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first, PACKET_STATE_DEAD); - dead = true; + state = PACKET_STATE_DEAD; break; } } - if (unlikely(dead)) - continue; - queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first, PACKET_STATE_CRYPTED); + queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first, state); } chacha20poly1305_deinit_simd(have_simd); } |