aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-10-02 20:51:34 +0100
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-10-02 20:51:34 +0100
commit0e39a1a0890fe8fffe7ea296f8123197e9d34e8b (patch)
tree0b7a23f42fe82208729c6e8b8184960a50efefb0
parentAdd debug messages to ref counting (diff)
downloadwireguard-openbsd-0e39a1a0890fe8fffe7ea296f8123197e9d34e8b.tar.xz
wireguard-openbsd-0e39a1a0890fe8fffe7ea296f8123197e9d34e8b.zip
Add initiation attempt reset
-rw-r--r--src/if_wg.c10
-rw-r--r--src/wireguard.c8
-rw-r--r--src/wireguard.h1
3 files changed, 15 insertions, 4 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 4970c07..2b9dd5b 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -393,14 +393,15 @@ wg_route_broken(struct wg_route *r)
}
void
-wg_route_send_keepalive(struct wg_route *r)
+wg_route_send_keepalive(struct wg_route *route)
{
struct wg_session *session;
- if ((session = wg_peer_ks_session(r->r_peer)) != NULL) {
- wg_route_queue(r, WG_PKT_TRANSPORT, session->s_local_id);
+ if ((session = wg_peer_ks_session(route->r_peer)) != NULL) {
+ wg_route_queue(route, WG_PKT_TRANSPORT, session->s_local_id);
wg_session_put(session);
} else {
- wg_route_send_initiation(r);
+ wg_peer_reset_attempts(route->r_peer);
+ wg_route_send_initiation(route);
}
}
@@ -729,6 +730,7 @@ wg_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa,
if ((session = wg_peer_ks_session(route->r_peer)) == NULL) {
if (mq_push(&route->r_outgoing, m) != 0)
counters_inc(sc->sc_if.if_counters, ifc_oqdrops);
+ wg_peer_reset_attempts(route->r_peer);
wg_route_send_initiation(route);
return 0;
}
diff --git a/src/wireguard.c b/src/wireguard.c
index 4b8005f..eeb7d40 100644
--- a/src/wireguard.c
+++ b/src/wireguard.c
@@ -258,6 +258,14 @@ wg_peer_attach_session(struct wg_peer *peer, struct wg_session *session)
}
void
+wg_peer_reset_attempts(struct wg_peer *peer)
+{
+ rw_enter_write(&peer->p_lock);
+ peer->p_attempts = 0;
+ rw_exit_write(&peer->p_lock);
+}
+
+void
wg_session_promote(struct wg_session *session)
{
struct wg_session *old_session;
diff --git a/src/wireguard.h b/src/wireguard.h
index 7853ba6..7ddf5e2 100644
--- a/src/wireguard.h
+++ b/src/wireguard.h
@@ -253,6 +253,7 @@ void wg_peer_ref(struct wg_peer *);
void wg_peer_put(struct wg_peer *);
void wg_peer_drop(struct wg_peer *);
void wg_peer_attach_session(struct wg_peer *, struct wg_session *);
+void wg_peer_reset_attempts(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_clean(struct wg_peer *);