From 448c7f898227448130a66126870c5f1a718af3ae Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 12 Oct 2017 03:39:10 +0200 Subject: send: improve dead packet control flow --- src/send.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/send.c b/src/send.c index 6a77a25..05a8472 100644 --- a/src/send.c +++ b/src/send.c @@ -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); } -- cgit v1.2.3-59-g8ed1b