]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP2: Close incomplete Relay connections
authorDisha Das <dishad@codeaurora.org>
Thu, 11 Feb 2021 08:36:47 +0000 (14:06 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 12 Apr 2021 21:26:07 +0000 (00:26 +0300)
Add timeout to close incomplete DPP relay connections. This is needed to
avoid getting stuck with old entries that prevent new connections from
getting started.

Signed-off-by: Disha Das <dishad@codeaurora.org>
src/common/dpp_tcp.c

index 609c243a68569b7be5718a3e000cdefef6c210d1..ddc720fecbed82045f050bc0afca4f79a41782c7 100644 (file)
@@ -82,6 +82,7 @@ static void dpp_controller_auth_success(struct dpp_connection *conn,
                                        int initiator);
 static void dpp_tcp_build_csr(void *eloop_ctx, void *timeout_ctx);
 static void dpp_tcp_gas_query_comeback(void *eloop_ctx, void *timeout_ctx);
+static void dpp_relay_conn_timeout(void *eloop_ctx, void *timeout_ctx);
 
 
 static void dpp_connection_free(struct dpp_connection *conn)
@@ -97,6 +98,7 @@ static void dpp_connection_free(struct dpp_connection *conn)
                             conn, NULL);
        eloop_cancel_timeout(dpp_tcp_build_csr, conn, NULL);
        eloop_cancel_timeout(dpp_tcp_gas_query_comeback, conn, NULL);
+       eloop_cancel_timeout(dpp_relay_conn_timeout, conn, NULL);
        wpabuf_free(conn->msg);
        wpabuf_free(conn->msg_out);
        dpp_auth_deinit(conn->auth);
@@ -352,6 +354,16 @@ static int dpp_ipaddr_to_sockaddr(struct sockaddr *addr, socklen_t *addrlen,
 }
 
 
+static void dpp_relay_conn_timeout(void *eloop_ctx, void *timeout_ctx)
+{
+       struct dpp_connection *conn = eloop_ctx;
+
+       wpa_printf(MSG_DEBUG,
+                  "DPP: Timeout while waiting for relayed connection to complete");
+       dpp_connection_remove(conn);
+}
+
+
 static struct dpp_connection *
 dpp_relay_new_conn(struct dpp_relay_controller *ctrl, const u8 *src,
                   unsigned int freq)
@@ -412,8 +424,8 @@ dpp_relay_new_conn(struct dpp_relay_controller *ctrl, const u8 *src,
                goto fail;
        conn->write_eloop = 1;
 
-       /* TODO: eloop timeout to clear a connection if it does not complete
-        * properly */
+       eloop_cancel_timeout(dpp_relay_conn_timeout, conn, NULL);
+       eloop_register_timeout(20, 0, dpp_relay_conn_timeout, conn, NULL);
 
        dl_list_add(&ctrl->conn, &conn->list);
        return conn;