From 71a7269d778f9a131d1cecbfdb3cd00c248131a8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 22 Apr 2020 02:04:22 -0600 Subject: wireguard: split CRYPTED/UNCRYPTED into {EN,DE}CRYPTED/NOT_{EN,DE}CRYPTED By splitting the enum into all possibilities, rather than having the {EN,DE} prefix being implicit based on context, it allows us to later merge processing of encryption and decryption into the same context. Signed-off-by: Jason A. Donenfeld --- drivers/net/wireguard/receive.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireguard/receive.c') diff --git a/drivers/net/wireguard/receive.c b/drivers/net/wireguard/receive.c index 4daa1b7..dd80650 100644 --- a/drivers/net/wireguard/receive.c +++ b/drivers/net/wireguard/receive.c @@ -414,13 +414,13 @@ int wg_packet_rx_poll(struct napi_struct *napi, int budget) while ((skb = __ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read_acquire(&PACKET_CB(skb)->state)) != - PACKET_STATE_UNCRYPTED) { + PACKET_STATE_NOT_DECRYPTED) { __ptr_ring_discard_one(&queue->ring); peer = PACKET_PEER(skb); keypair = PACKET_CB(skb)->keypair; free = true; - if (unlikely(state != PACKET_STATE_CRYPTED)) + if (unlikely(state != PACKET_STATE_DECRYPTED)) goto next; if (unlikely(!counter_validate(&keypair->receiving.counter, @@ -475,7 +475,8 @@ static void wg_packet_consume_data(struct wg_device *wg, struct sk_buff *skb) ret = wg_queue_enqueue_per_device_and_peer(&wg->decrypt_queue, &peer->rx_queue, skb, wg->packet_crypt_wq, - &wg->decrypt_queue.last_cpu); + &wg->decrypt_queue.last_cpu, + PACKET_STATE_NOT_DECRYPTED); if (unlikely(ret == -EPIPE)) wg_queue_enqueue_per_peer_napi(skb, PACKET_STATE_DEAD); if (likely(!ret || ret == -EPIPE)) { -- cgit v1.2.3