aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-10-06 19:07:46 +0100
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-10-07 10:28:41 +0100
commite1e06c7384439ccb3e5727812cf734f69335e9d2 (patch)
tree3f6e27b3e832ad8a5f003a85f8365123f39916ab
parentUse mutexes in wireguard rather than rwlocks (diff)
downloadwireguard-openbsd-e1e06c7384439ccb3e5727812cf734f69335e9d2.tar.xz
wireguard-openbsd-e1e06c7384439ccb3e5727812cf734f69335e9d2.zip
Add beginnings of mutex filled get* functions
-rw-r--r--src/if_wg.c4
-rw-r--r--src/wireguard.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 97fdf83..a98fa4e 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -1192,7 +1192,7 @@ wg_ioctl_serv_get(struct wg_softc *sc, struct wg_serv_get *wgs)
/* TODO We only want to pass the private key to root */
wgs->gs_port = sc->sc_port;
- wgs->gs_keypair = sc->sc_dev.d_keypair;
+ wg_device_getkey(&sc->sc_dev, &wgs->gs_keypair, 1);
/* For the time being, no lock as we hold kernel lock in ioctl */
FM_FOREACH_FILLED(item, &sc->sc_dev.d_peers) {
@@ -1218,7 +1218,7 @@ wg_ioctl_peer_get(struct wg_softc *sc, struct wg_peer_get *wgp)
route = peer->p_arg;
/* TODO We only want to pass the preshared key to root */
- wg_peer_getshared(peer, &wgp->gp_shared);
+ wg_peer_getshared(peer, &wgp->gp_shared, 1);
wgp->gp_last_handshake = wg_peer_last_handshake(peer);
wgp->gp_pka = wg_timer_persistent_keepalive_get(&peer->p_timers);
diff --git a/src/wireguard.h b/src/wireguard.h
index 80b35ac..040ad97 100644
--- a/src/wireguard.h
+++ b/src/wireguard.h
@@ -254,6 +254,7 @@ void wg_device_init(struct wg_device *, int,
void (*)(struct wg_peer *, enum wg_pkt_type, uint32_t),
void (*)(struct wg_peer *), void *);
void wg_device_setkey(struct wg_device *, struct wg_privkey *);
+void wg_device_getkey(struct wg_device *, struct wg_keypair *, int);
void wg_device_destroy(struct wg_device *);
struct wg_peer *wg_device_new_peer(struct wg_device *, struct wg_pubkey *, void *);
@@ -265,7 +266,7 @@ void wg_peer_drop(struct wg_peer *);
void wg_peer_reset_attempts(struct wg_peer *);
void wg_peer_clean(struct wg_peer *);
void wg_peer_setshared(struct wg_peer *, struct wg_privkey *);
-void wg_peer_getshared(struct wg_peer *, struct wg_privkey *);
+void wg_peer_getshared(struct wg_peer *, struct wg_privkey *, int);
struct timespec wg_peer_last_handshake(struct wg_peer *);
struct wg_session *wg_peer_last_session(struct wg_peer *);