aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/wg/if_wg.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c
index 89b5e52b7b2b..6638524301b8 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -1519,8 +1519,7 @@ wg_encrypt(struct wg_softc *sc, struct wg_packet *pkt)
state = WG_PACKET_CRYPTED;
out:
pkt->p_mbuf = m;
- wmb();
- pkt->p_state = state;
+ atomic_store_rel_int(&pkt->p_state, state);
GROUPTASK_ENQUEUE(&peer->p_send);
noise_remote_put(remote);
}
@@ -1592,8 +1591,7 @@ wg_decrypt(struct wg_softc *sc, struct wg_packet *pkt)
state = WG_PACKET_CRYPTED;
out:
pkt->p_mbuf = m;
- wmb();
- pkt->p_state = state;
+ atomic_store_rel_int(&pkt->p_state, state);
GROUPTASK_ENQUEUE(&peer->p_recv);
noise_remote_put(remote);
}
@@ -1649,7 +1647,7 @@ wg_deliver_out(struct wg_peer *peer)
wg_peer_get_endpoint(peer, &endpoint);
while ((pkt = wg_queue_dequeue_serial(&peer->p_encrypt_serial)) != NULL) {
- if (pkt->p_state != WG_PACKET_CRYPTED)
+ if (atomic_load_acq_int(&pkt->p_state) != WG_PACKET_CRYPTED)
goto error;
m = pkt->p_mbuf;
@@ -1691,7 +1689,7 @@ wg_deliver_in(struct wg_peer *peer)
struct epoch_tracker et;
while ((pkt = wg_queue_dequeue_serial(&peer->p_decrypt_serial)) != NULL) {
- if (pkt->p_state != WG_PACKET_CRYPTED)
+ if (atomic_load_acq_int(&pkt->p_state) != WG_PACKET_CRYPTED)
goto error;
m = pkt->p_mbuf;