aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-22 23:02:41 +0200
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-22 23:02:41 +0200
commit6147186e478c3b62a3b03205ea8c0d61b655395b (patch)
treedb48034fd24923669f7f3142c6413d04234f30ec
parentBe more strict on state checking (diff)
downloadwireguard-openbsd-6147186e478c3b62a3b03205ea8c0d61b655395b.tar.xz
wireguard-openbsd-6147186e478c3b62a3b03205ea8c0d61b655395b.zip
Rename WG_PKT_STATE_PASS to WG_PKT_STATE_REQUEUED
-rw-r--r--src/if_wg.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 11188a0..35e6b92 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -59,7 +59,7 @@ struct wg_tag {
WG_PKT_STATE_NEW,
WG_PKT_STATE_DONE,
WG_PKT_STATE_DEAD,
- WG_PKT_STATE_PASS,
+ WG_PKT_STATE_REQUEUED,
} t_state;
};
@@ -647,7 +647,7 @@ wg_encrypt(struct mbuf *m)
struct wg_tag *tag = wg_mbuf_get_tag(m);
struct wg_peer *p = tag->t_peer;
- if (tag->t_state != WG_PKT_STATE_NEW && tag->t_state != WG_PKT_STATE_PASS)
+ if (tag->t_state != WG_PKT_STATE_NEW && tag->t_state != WG_PKT_STATE_REQUEUED)
panic("not a new/pass state packet: %d\n", tag->t_state);
em = m_clget(NULL, M_WAITOK, total_len);
@@ -665,7 +665,7 @@ wg_encrypt(struct mbuf *m)
counters_inc(p->p_sc->sc_if.if_counters, ifc_oqdrops);
wg_peer_init(p);
m_freem(em);
- tag->t_state = WG_PKT_STATE_PASS;
+ tag->t_state = WG_PKT_STATE_REQUEUED;
return;
default:
goto free;
@@ -1004,6 +1004,8 @@ wg_input_deliver(struct mbuf *m)
m_freem(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)
+ panic("unexpected state on: %p\n", m);
else if (tag->t_state == WG_PKT_STATE_DONE) {
fn_input = AF_VAL(m->m_pkthdr.ph_family, ipv4_input, ipv6_input);
NET_LOCK();
@@ -1013,8 +1015,7 @@ wg_input_deliver(struct mbuf *m)
panic("invalid af");
NET_UNLOCK();
} else {
- m_freem(m);
- DPRINTF(sc, "did not input packet\n");
+ panic("invalid state: %d\n", tag->t_state);
}
}
@@ -1032,6 +1033,8 @@ wg_output_deliver(struct mbuf *m)
m_freem(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");
else if (tag->t_state == WG_PKT_STATE_DONE) {
bzero(&peernam, sizeof(struct mbuf));
@@ -1050,8 +1053,7 @@ wg_output_deliver(struct mbuf *m)
}
sounlock(so, s);
} else {
- /* Don't free as packet was queued for handshake */
- DPRINTF(sc, "did not output packet\n");
+ panic("invalid state: %d\n", tag->t_state);
}
}