aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/if_wg.c9
-rw-r--r--src/wg_noise.c10
2 files changed, 10 insertions, 9 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index c1ebb0c..a64403b 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -1260,7 +1260,6 @@ wg_handshake(struct wg_softc *sc, struct wg_packet *pkt)
struct wg_endpoint *e;
struct wg_peer *peer;
struct mbuf *m;
- struct noise_keypair *keypair;
struct noise_remote *remote = NULL;
int res, underload = 0;
static struct timeval wg_last_underload; /* microuptime */
@@ -1353,12 +1352,8 @@ wg_handshake(struct wg_softc *sc, struct wg_packet *pkt)
cook = mtod(m, struct wg_pkt_cookie *);
if ((remote = noise_remote_index_lookup(sc->sc_local, cook->r_idx)) == NULL) {
- if ((keypair = noise_keypair_lookup(sc->sc_local, cook->r_idx)) == NULL) {
- DPRINTF(sc, "Unknown cookie index\n");
- goto error;
- }
- remote = noise_keypair_remote(keypair);
- noise_keypair_put(keypair);
+ DPRINTF(sc, "Unknown cookie index\n");
+ goto error;
}
peer = noise_remote_arg(remote);
diff --git a/src/wg_noise.c b/src/wg_noise.c
index 7cf160b..4a1134d 100644
--- a/src/wg_noise.c
+++ b/src/wg_noise.c
@@ -380,13 +380,19 @@ noise_remote_index_lookup(struct noise_local *l, uint32_t idx0)
{
struct epoch_tracker et;
struct noise_index *i;
+ struct noise_keypair *kp;
struct noise_remote *r, *ret = NULL;
uint32_t idx = idx0 & HT_INDEX_MASK;
NET_EPOCH_ENTER(et);
CK_LIST_FOREACH(i, &l->l_index_hash[idx], i_entry) {
- if (i->i_local_index == idx0 && !i->i_is_keypair) {
- r = (struct noise_remote *) i;
+ if (i->i_local_index == idx0) {
+ if (i->i_is_keypair) {
+ kp = (struct noise_keypair *) i;
+ r = kp->kp_remote;
+ } else {
+ r = (struct noise_remote *) i;
+ }
if (refcount_acquire_if_not_zero(&r->r_refcnt))
ret = r;
break;