aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-22 17:17:25 +0200
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-22 17:17:25 +0200
commit28cdf801a20436a5061bd9785c9c28fc59820000 (patch)
treea4f375db8905ef4afec2fb642da103d1adcf17cd
parentAdd second queue for incoming handshake packets (diff)
downloadwireguard-openbsd-28cdf801a20436a5061bd9785c9c28fc59820000.tar.xz
wireguard-openbsd-28cdf801a20436a5061bd9785c9c28fc59820000.zip
Change rx queues to use mpq
-rw-r--r--src/if_wg.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 51112e3..e3512ff 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -108,8 +108,8 @@ struct wg_softc {
struct mpq sc_tx_queue;
struct mpq sc_tx_slow_queue;
- struct mbuf_queue sc_rx_queue;
- struct mbuf_queue sc_rx_slow_queue;
+ struct mpq sc_rx_queue;
+ struct mpq sc_rx_slow_queue;
struct fixed_map sc_id_map;
RB_HEAD(peer_tree, wg_peer) sc_peer_tree;
@@ -185,6 +185,8 @@ RB_GENERATE(peer_tree, wg_peer, p_entry, wg_peer_cmp)
MPQ_WORKER(wg_tx_slow_task_fn, wg_encrypt_hs, wg_output_deliver);
MPQ_WORKER(wg_tx_task_fn, wg_encrypt, wg_output_deliver);
+MPQ_WORKER(wg_rx_slow_task_fn, wg_decrypt_hs, m_freem);
+MPQ_WORKER(wg_rx_task_fn, wg_decrypt, wg_input_deliver);
struct wg_peer *
wg_softc_peer_create(struct wg_softc *sc, uint8_t key[WG_KEY_SIZE])
@@ -860,30 +862,6 @@ error:
counters_inc(sc->sc_if.if_counters, ifc_ierrors);
}
-void
-wg_rx_slow_task_fn(void *_sc)
-{
- struct mbuf *m;
- struct wg_softc *sc = _sc;
-
- while ((m = mq_dequeue(&sc->sc_rx_slow_queue)) != NULL) {
- wg_decrypt_hs(m);
- m_freem(m);
- }
-}
-
-void
-wg_rx_task_fn(void *_sc)
-{
- struct mbuf *m;
- struct wg_softc *sc = _sc;
-
- while ((m = mq_dequeue(&sc->sc_rx_queue)) != NULL) {
- wg_decrypt(m);
- wg_input_deliver(m);
- }
-}
-
/* The following functions are the stack facing network functions. They will
* handle packets in and out for sending and receiving.
*/
@@ -971,11 +949,11 @@ wg_input(void *_sc, struct mbuf *m, struct sockaddr *sa, int hlen)
case WG_PKT_INITIATION:
case WG_PKT_RESPONSE:
case WG_PKT_COOKIE:
- mq_enqueue(&sc->sc_rx_slow_queue, m);
+ mpq_enqueue(&sc->sc_rx_slow_queue, m);
task_add(sc->sc_taskq, &sc->sc_rx_slow_task);
break;
case WG_PKT_TRANSPORT:
- mq_enqueue(&sc->sc_rx_queue, m);
+ mpq_enqueue(&sc->sc_rx_queue, m);
task_add(sc->sc_taskq, &sc->sc_rx_task);
break;
default:
@@ -1094,12 +1072,12 @@ wg_clone_create(struct if_clone * ifc, int unit)
sc->sc_taskq = taskq_create("wg", 1, IPL_NET, TASKQ_MPSAFE);
task_set(&sc->sc_tx_task, wg_tx_task_fn, &sc->sc_tx_queue);
task_set(&sc->sc_tx_slow_task, wg_tx_slow_task_fn, &sc->sc_tx_slow_queue);
- task_set(&sc->sc_rx_task, wg_rx_task_fn, sc);
- task_set(&sc->sc_rx_slow_task, wg_rx_slow_task_fn, sc);
+ task_set(&sc->sc_rx_task, wg_rx_task_fn, &sc->sc_rx_queue);
+ task_set(&sc->sc_rx_slow_task, wg_rx_slow_task_fn, &sc->sc_rx_slow_queue);
mpq_init(&sc->sc_tx_queue, IPL_NET);
mpq_init(&sc->sc_tx_slow_queue, IPL_NET);
- mq_init(&sc->sc_rx_queue, 1024, IPL_NET);
- mq_init(&sc->sc_rx_slow_queue, 10, IPL_NET);
+ mpq_init(&sc->sc_rx_queue, IPL_NET);
+ mpq_init(&sc->sc_rx_slow_queue, IPL_NET);
/* ifnet */