summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/net/if_wg.c52
1 files changed, 20 insertions, 32 deletions
diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c
index 0f09d8170bf..d29d98218dc 100644
--- a/sys/net/if_wg.c
+++ b/sys/net/if_wg.c
@@ -195,9 +195,6 @@ struct wg_peer {
struct mutex p_endpoint_mtx;
struct wg_endpoint p_endpoint;
- struct task p_send_initiation;
- struct task p_send_keepalive;
- struct task p_clear_secrets;
struct task p_deliver_out;
struct task p_deliver_in;
@@ -299,12 +296,11 @@ void wg_timers_run_zero_key_material(void *);
void wg_timers_run_persistent_keepalive(void *);
void wg_peer_send_buf(struct wg_peer *, uint8_t *, size_t);
-void wg_send_initiation(void *);
+void wg_send_initiation(struct wg_peer *);
void wg_send_response(struct wg_peer *);
void wg_send_cookie(struct wg_softc *, struct cookie_macs *, uint32_t,
struct wg_endpoint *e);
-void wg_send_keepalive(void *);
-void wg_peer_clear_secrets(void *);
+void wg_send_keepalive(struct wg_peer *);
void wg_handshake(struct wg_softc *, struct wg_packet *);
void wg_handshake_worker(void *);
@@ -376,9 +372,6 @@ wg_peer_create(struct wg_softc *sc, uint8_t public[WG_KEY_SIZE],
mtx_init(&peer->p_endpoint_mtx, IPL_NET);
bzero(&peer->p_endpoint, sizeof(peer->p_endpoint));
- task_set(&peer->p_send_initiation, wg_send_initiation, peer);
- task_set(&peer->p_send_keepalive, wg_send_keepalive, peer);
- task_set(&peer->p_clear_secrets, wg_peer_clear_secrets, peer);
task_set(&peer->p_deliver_out, wg_deliver_out, peer);
task_set(&peer->p_deliver_in, wg_deliver_in, peer);
@@ -825,13 +818,16 @@ wg_timers_init(struct wg_timers *t)
rw_init(&t->t_lock, "wg_timers");
mtx_init(&t->t_handshake_mtx, IPL_NET);
- timeout_set(&t->t_new_handshake, wg_timers_run_new_handshake, t);
- timeout_set(&t->t_send_keepalive, wg_timers_run_send_keepalive, t);
- timeout_set(&t->t_retry_handshake, wg_timers_run_retry_handshake, t);
- timeout_set(&t->t_persistent_keepalive,
- wg_timers_run_persistent_keepalive, t);
- timeout_set(&t->t_zero_key_material,
- wg_timers_run_zero_key_material, t);
+ timeout_set_flags(&t->t_new_handshake,
+ wg_timers_run_new_handshake, t, TIMEOUT_PROC);
+ timeout_set_flags(&t->t_send_keepalive,
+ wg_timers_run_send_keepalive, t, TIMEOUT_PROC);
+ timeout_set_flags(&t->t_retry_handshake,
+ wg_timers_run_retry_handshake, t, TIMEOUT_PROC);
+ timeout_set_flags(&t->t_persistent_keepalive,
+ wg_timers_run_persistent_keepalive, t, TIMEOUT_PROC);
+ timeout_set_flags(&t->t_zero_key_material,
+ wg_timers_run_zero_key_material, t, TIMEOUT_PROC);
}
void
@@ -986,7 +982,7 @@ wg_timers_run_send_initiation(void *_t, int is_retry)
if (!is_retry)
t->t_handshake_retries = 0;
if (noise_remote_initiation_expired(peer->p_remote) == ETIMEDOUT)
- task_add(wg_handshake_taskq, &peer->p_send_initiation);
+ wg_send_initiation(peer);
}
void
@@ -1026,7 +1022,7 @@ wg_timers_run_send_keepalive(void *_t)
struct wg_timers *t = _t;
struct wg_peer *peer = CONTAINER_OF(t, struct wg_peer, p_timers);
- task_add(wg_crypt_taskq, &peer->p_send_keepalive);
+ wg_send_keepalive(peer);
if (t->t_need_another_keepalive) {
t->t_need_another_keepalive = 0;
timeout_add_sec(&t->t_send_keepalive, KEEPALIVE_TIMEOUT);
@@ -1042,8 +1038,8 @@ wg_timers_run_new_handshake(void *_t)
DPRINTF(peer->p_sc, "Retrying handshake with peer %llu because we "
"stopped hearing back after %d seconds\n",
peer->p_id, NEW_HANDSHAKE_TIMEOUT);
- wg_peer_clear_src(peer);
+ wg_peer_clear_src(peer);
wg_timers_run_send_initiation(t, 0);
}
@@ -1056,7 +1052,7 @@ wg_timers_run_zero_key_material(void *_t)
DPRINTF(peer->p_sc, "Zeroing out keys for peer %llu, since we "
"haven't received a new one in %d seconds\n",
peer->p_id, REJECT_AFTER_TIME * 3);
- task_add(wg_handshake_taskq, &peer->p_clear_secrets);
+ noise_remote_keypairs_clear(peer->p_remote);
}
void
@@ -1064,8 +1060,9 @@ wg_timers_run_persistent_keepalive(void *_t)
{
struct wg_timers *t = _t;
struct wg_peer *peer = CONTAINER_OF(t, struct wg_peer, p_timers);
+
if (t->t_persistent_keepalive_interval > 0)
- task_add(wg_crypt_taskq, &peer->p_send_keepalive);
+ wg_send_keepalive(peer);
}
/* The following functions handle handshakes */
@@ -1082,9 +1079,8 @@ wg_peer_send_buf(struct wg_peer *peer, uint8_t *buf, size_t len)
}
void
-wg_send_initiation(void *_peer)
+wg_send_initiation(struct wg_peer *peer)
{
- struct wg_peer *peer = _peer;
struct wg_pkt_initiation pkt;
if (noise_create_initiation(peer->p_remote, &pkt.s_idx, pkt.ue, pkt.es,
@@ -1138,9 +1134,8 @@ wg_send_cookie(struct wg_softc *sc, struct cookie_macs *cm, uint32_t idx,
}
void
-wg_send_keepalive(void *_peer)
+wg_send_keepalive(struct wg_peer *peer)
{
- struct wg_peer *peer = _peer;
struct wg_softc *sc = peer->p_sc;
struct wg_packet *pkt;
struct mbuf *m;
@@ -1170,13 +1165,6 @@ send:
}
void
-wg_peer_clear_secrets(void *_peer)
-{
- struct wg_peer *peer = _peer;
- noise_remote_keypairs_clear(peer->p_remote);
-}
-
-void
wg_handshake(struct wg_softc *sc, struct wg_packet *pkt)
{
struct wg_pkt_initiation *init;