diff options
Diffstat (limited to 'src/receive.c')
-rw-r--r-- | src/receive.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/receive.c b/src/receive.c index 5ab4171..3de698f 100644 --- a/src/receive.c +++ b/src/receive.c @@ -378,18 +378,8 @@ void packet_rx_worker(struct work_struct *work) bool free; local_bh_disable(); - /*spin_lock_bh(&queue->ring.consumer_lock);*/ - /*while ((skb = __ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read(&PACKET_CB(skb)->state)) != PACKET_STATE_UNCRYPTED) {*/ - /*__ptr_ring_discard_one(&queue->ring);*/ - - // TODO: this is very wrong - while (ck_ring_dequeue_mpmc(&queue->ring, &queue->ring_buffer, &skb)) { - if ((state = atomic_read(&PACKET_CB(skb)->state)) == PACKET_STATE_UNCRYPTED) { - ck_ring_enqueue_mpmc(&queue->ring, &queue->ring_buffer, &skb); // ignores error - continue; - } - - + while (mpmc_ptr_ring_peek(&queue->ring, &skb, sizeof(struct sk_buff*)) && (state = atomic_read(&PACKET_CB(skb)->state)) != PACKET_STATE_UNCRYPTED) { + mpmc_ptr_ring_discard(&queue->ring); peer = PACKET_PEER(skb); keypair = PACKET_CB(skb)->keypair; free = true; @@ -415,7 +405,6 @@ next: if (unlikely(free)) dev_kfree_skb(skb); } - /*spin_unlock_bh(&queue->ring.consumer_lock);*/ local_bh_enable(); } @@ -425,8 +414,7 @@ void packet_decrypt_worker(struct work_struct *work) struct sk_buff *skb; bool have_simd = chacha20poly1305_init_simd(); - /*while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {*/ - while (ck_ring_dequeue_mpmc(&queue->ring, &queue->ring_buffer, &skb)) { + while (ck_ring_dequeue_mpmc(&queue->ring, &skb)) { enum packet_state state = likely(skb_decrypt(skb, &PACKET_CB(skb)->keypair->receiving, have_simd)) ? PACKET_STATE_CRYPTED : PACKET_STATE_DEAD; queue_enqueue_per_peer(&PACKET_PEER(skb)->rx_queue, skb, state); |