aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-28 12:44:27 +0100
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-28 12:44:27 +0100
commitd89af84ddc40436e1d879de3145235b8a35dd7d1 (patch)
treef95a6d494356de9f727d40f7f0b697d8680ee4fb
parentAdjust queueing process (diff)
downloadwireguard-openbsd-d89af84ddc40436e1d879de3145235b8a35dd7d1.tar.xz
wireguard-openbsd-d89af84ddc40436e1d879de3145235b8a35dd7d1.zip
Add more verbose messages
-rw-r--r--src/if_wg.c14
-rw-r--r--src/kern_wg.c26
-rw-r--r--src/mpq.h6
3 files changed, 22 insertions, 24 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index e4fd4fe..24cb33e 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -122,6 +122,8 @@ struct bloom_bucket wg_bb;
#define DPRINTF_ERROR(sc, m, e) DPRINTF(sc, "%s: %s\n", m, wg_error_str[e])
#define DPRINTF_HS(sc, m, hs) DPRINTF(sc, "peer %x: %s\n", \
wg_handshake_shortkey(hs), m)
+#define DPRINTF_HS_SESS(sc, m, hs, sess) DPRINTF(sc, "peer %x (%x): %s\n", \
+ wg_handshake_shortkey(hs), wg_session_id(sess), m)
#define DPRINTF_HS_ERROR(sc, m, hs, e) DPRINTF(sc, "peer %x: %s: %s\n", \
wg_handshake_shortkey(hs), m, wg_error_str[e])
@@ -477,7 +479,7 @@ wg_peer_init(struct wg_peer *p)
void
wg_peer_broken(struct wg_peer *p)
{
- DPRINTF_HS(p->p_sc, "broken session detected", &p->p_hs);
+ DPRINTF_HS_SESS(p->p_sc, "broken", &p->p_hs, &p->p_sess);
wg_peer_cleanup(p);
wg_peer_init(p);
}
@@ -504,7 +506,7 @@ wg_peer_new_session(struct wg_peer *p)
return;
}
- DPRINTF_HS(p->p_sc, "created session", &p->p_hs);
+ DPRINTF_HS_SESS(p->p_sc, "session created", &p->p_hs, &p->p_sess);
wg_timer_session_made(&p->p_timers);
wg_timer_reinit_unflag(&p->p_timers);
@@ -679,7 +681,7 @@ wg_encrypt(struct mbuf *m)
ifc_obytes, m->m_pkthdr.len);
wg_timer_broken_flag(&p->p_timers);
} else {
- DPRINTF_HS(p->p_sc, "send keepalive", &p->p_hs);
+ DPRINTF_HS_SESS(p->p_sc, "tx keepalive", &p->p_hs, &p->p_sess);
}
wg_timer_keepalive_unflag(&p->p_timers);
@@ -838,7 +840,7 @@ wg_decrypt(struct mbuf *m)
wg_timer_persistent_keepalive_tick(&p->p_timers);
wg_timer_broken_unflag(&p->p_timers);
tag->t_state = WG_PKT_STATE_DEAD;
- DPRINTF_HS(sc, "receive keepalive", &p->p_hs);
+ DPRINTF_HS_SESS(p->p_sc, "rx keepalive", &p->p_hs, &p->p_sess);
return;
}
@@ -1039,7 +1041,7 @@ wg_output_deliver(struct mbuf *m)
else if (tag->t_state == WG_PKT_STATE_NEW)
panic("unexpected state on: %p\n", m);
else if (tag->t_state == WG_PKT_STATE_REQUEUED)
- DPRINTF(sc, "did not output packet\n");
+ DPRINTF_HS(sc, "data packet waiting for session\n", &tag->t_peer->p_hs);
else if (tag->t_state == WG_PKT_STATE_DONE) {
em = m->m_pkthdr.ph_cookie;
if (em != m)
@@ -1122,7 +1124,7 @@ wg_clone_create(struct if_clone * ifc, int unit)
snprintf(ifp->if_xname, sizeof(ifp->if_xname), "wg%d", unit);
ifp->if_mtu = 1420;
- ifp->if_flags = IFF_NOARP | IFF_MULTICAST | IFF_BROADCAST;
+ ifp->if_flags = IFF_DEBUG | IFF_NOARP | IFF_MULTICAST | IFF_BROADCAST;
ifp->if_xflags = IFXF_CLONED;
ifp->if_ioctl = wg_ioctl;
diff --git a/src/kern_wg.c b/src/kern_wg.c
index eb9ec02..c319523 100644
--- a/src/kern_wg.c
+++ b/src/kern_wg.c
@@ -285,12 +285,11 @@ mpq_full(struct mpq *mpq)
{
int full;
mtx_enter(&mpq->mpq_mtx);
- full = ml_len(&mpq->mpq_list) > MPQ_LEN;
+ full = ml_len(&mpq->mpq_list) >= MPQ_LEN;
mtx_leave(&mpq->mpq_mtx);
return full;
}
-
int
mpq_serialize_try_enter(struct mpq *mpq)
{
@@ -312,11 +311,17 @@ mpq_serialize_leave(struct mpq *mpq)
mtx_leave(&mpq->mpq_mtx);
}
-int
+void
+mpq_threaddone(struct mpq *mpq, struct mbuf *m)
+{
+ mtx_enter(&mpq->mpq_mtx);
+ SET(m->m_flags, M_LINK0);
+ mtx_leave(&mpq->mpq_mtx);
+}
+
+void
mpq_enqueue(struct mpq *mpq, struct mbuf *m)
{
- /* TODO time based dropping of packets */
- int dropped = 0;
CLR(m->m_flags, M_LINK0);
mtx_enter(&mpq->mpq_mtx);
if (ml_len(&mpq->mpq_list) < MPQ_LEN) {
@@ -324,18 +329,9 @@ mpq_enqueue(struct mpq *mpq, struct mbuf *m)
if (mpq->mpq_cursor == NULL)
mpq->mpq_cursor = m;
} else {
- dropped = 1;
+ m_freem(m);
}
mtx_leave(&mpq->mpq_mtx);
- return dropped;
-}
-
-void
-mpq_enlist(struct mpq *mpq, struct mbuf_list *list)
-{
- mtx_enter(&mpq->mpq_mtx);
- ml_enlist(&mpq->mpq_list, list);
- mtx_leave(&mpq->mpq_mtx);
}
struct mbuf
diff --git a/src/mpq.h b/src/mpq.h
index b818f6b..70f0dba 100644
--- a/src/mpq.h
+++ b/src/mpq.h
@@ -32,8 +32,8 @@ 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 *);
-void mpq_enlist(struct mpq *, struct mbuf_list *);
+void mpq_threaddone(struct mpq *, struct mbuf *);
+void mpq_enqueue(struct mpq *, struct mbuf *);
struct mbuf *mpq_dethread(struct mpq *);
struct mbuf *mpq_dequeue(struct mpq *);
void mpq_done(struct mbuf *m);
@@ -45,7 +45,7 @@ void fn_name(void *_mpq) { \
struct mpq *mpq = _mpq; \
while ((m = mpq_dethread(mpq)) != NULL) { \
parallel_fn(m); \
- SET(m->m_flags, M_LINK0); \
+ mpq_threaddone(mpq, m); \
} \
if (mpq_serialize_try_enter(mpq) == 0) { \
while((m = mpq_dequeue(mpq)) != NULL) { \