aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-27 21:02:37 +0100
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-27 21:02:37 +0100
commit4d1341e480a1726df9815696b7cfe81fe1bed5b4 (patch)
tree65baa7a0001dce345570186f9bf98f47df026584
parentAttempt to start the interface if the queue is full (diff)
downloadwireguard-openbsd-4d1341e480a1726df9815696b7cfe81fe1bed5b4.tar.xz
wireguard-openbsd-4d1341e480a1726df9815696b7cfe81fe1bed5b4.zip
Adjust queueing process
-rw-r--r--src/if_wg.c9
-rw-r--r--src/kern_wg.c11
-rw-r--r--src/mpq.h1
3 files changed, 14 insertions, 7 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index d9c2150..e4fd4fe 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -887,13 +887,8 @@ wg_start(struct ifnet *ifp)
struct mbuf *m;
struct wg_softc *sc = ifp->if_softc;
- while ((m = ifq_deq_begin(&ifp->if_snd)) != NULL) {
- if (mpq_enqueue(&sc->sc_tx_queue, m) != 0) {
- ifq_deq_rollback(&ifp->if_snd, m);
- break;
- }
- ifq_deq_commit(&ifp->if_snd, m);
- }
+ while (!mpq_full(&sc->sc_tx_queue) && (m = ifq_dequeue(&ifp->if_snd)) != NULL)
+ mpq_enqueue(&sc->sc_tx_queue, m);
task_add(sc->sc_taskq, &sc->sc_tx_task);
}
diff --git a/src/kern_wg.c b/src/kern_wg.c
index 9839929..eb9ec02 100644
--- a/src/kern_wg.c
+++ b/src/kern_wg.c
@@ -281,6 +281,17 @@ mpq_init(struct mpq *mpq, int ipl)
}
int
+mpq_full(struct mpq *mpq)
+{
+ int full;
+ mtx_enter(&mpq->mpq_mtx);
+ full = ml_len(&mpq->mpq_list) > MPQ_LEN;
+ mtx_leave(&mpq->mpq_mtx);
+ return full;
+}
+
+
+int
mpq_serialize_try_enter(struct mpq *mpq)
{
int error = 1;
diff --git a/src/mpq.h b/src/mpq.h
index eda5cfa..b818f6b 100644
--- a/src/mpq.h
+++ b/src/mpq.h
@@ -29,6 +29,7 @@ struct mpq {
};
void mpq_init(struct mpq *, int);
+int mpq_full(struct mpq *);
int mpq_serialize_try_enter(struct mpq *);
void mpq_serialize_leave(struct mpq *);
int mpq_enqueue(struct mpq *, struct mbuf *);