aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/receive.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/receive.c')
-rw-r--r--src/receive.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/receive.c b/src/receive.c
index 27d3d04..5ab4171 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -378,9 +378,18 @@ 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);
+ /*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;
+ }
+
+
peer = PACKET_PEER(skb);
keypair = PACKET_CB(skb)->keypair;
free = true;
@@ -406,7 +415,7 @@ next:
if (unlikely(free))
dev_kfree_skb(skb);
}
- spin_unlock_bh(&queue->ring.consumer_lock);
+ /*spin_unlock_bh(&queue->ring.consumer_lock);*/
local_bh_enable();
}
@@ -416,7 +425,8 @@ 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 ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {*/
+ while (ck_ring_dequeue_mpmc(&queue->ring, &queue->ring_buffer, &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);