]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: release the TLS context asap from quic_conn_release()
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 6 Nov 2023 08:43:05 +0000 (09:43 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Thu, 9 Nov 2023 09:32:31 +0000 (10:32 +0100)
This was no reason not to release as soon as possible the TLS/SSL QUIC connection
context from quic_conn_release() before allocating a "closing connection" connection
(quic_cc_conn struct).

include/haproxy/quic_conn-t.h
src/quic_conn.c

index 01a98700e1458542aa7aabd450a81a62d86bb0e9..05b48f8905c9c6dcf318c1d3c431506adde9d4e8 100644 (file)
@@ -440,10 +440,6 @@ struct quic_conn_cntrs {
         /* Idle timer task */                                                  \
         struct task *idle_timer_task;                                          \
         unsigned int idle_expire;                                              \
-        struct ssl_sock_ctx *xprt_ctx;                                         \
-        /* Used only to reach the tasklet for the I/O handler from this        \
-         * quic_conn object.                                                   \
-         */                                                                    \
         /* QUIC connection level counters */                                   \
         struct quic_conn_cntrs cntrs;                                          \
         struct connection *conn;                                               \
@@ -451,6 +447,10 @@ struct quic_conn_cntrs {
 
 struct quic_conn {
        QUIC_CONN_COMMON;
+       /* Used only to reach the tasklet for the I/O handler from this
+        * quic_conn object.
+        */
+       struct ssl_sock_ctx *xprt_ctx;
        const struct quic_version *original_version;
        const struct quic_version *negotiated_version;
        /* Negotiated version Initial TLS context */
index 7515e8d00ee81ffc6d3f792e001f08a05a862232..d5d5adeaf832074133d36bc6e9c29089f65c4dfa 100644 (file)
@@ -770,7 +770,6 @@ static void quic_release_cc_conn(struct quic_cc_conn *cc_qc)
        pool_free(pool_head_quic_cc_buf, cc_qc->cc_buf_area);
        cc_qc->cc_buf_area = NULL;
        /* free the SSL sock context */
-       qc_free_ssl_sock_ctx(&cc_qc->xprt_ctx);
        pool_free(pool_head_quic_cc_conn, cc_qc);
 
        TRACE_ENTER(QUIC_EV_CONN_IO_CB);
@@ -878,8 +877,6 @@ static struct quic_cc_conn *qc_new_cc_conn(struct quic_conn *qc)
        cc_qc->idle_timer_task->context = cc_qc;
        cc_qc->idle_expire = qc->idle_expire;
 
-       cc_qc->xprt_ctx = qc->xprt_ctx;
-       qc->xprt_ctx = NULL;
        cc_qc->conn = qc->conn;
        qc->conn = NULL;
 
@@ -1472,8 +1469,6 @@ void quic_conn_release(struct quic_conn *qc)
                qc->cids = NULL;
                pool_free(pool_head_quic_cc_buf, qc->tx.cc_buf_area);
                qc->tx.cc_buf_area = NULL;
-               /* free the SSL sock context */
-               qc_free_ssl_sock_ctx(&qc->xprt_ctx);
        }
 
        /* in the unlikely (but possible) case the connection was just added to
@@ -1496,6 +1491,8 @@ void quic_conn_release(struct quic_conn *qc)
                qc_stream_desc_free(stream, 1);
        }
 
+       /* free the SSL sock context */
+       qc_free_ssl_sock_ctx(&qc->xprt_ctx);
        /* Purge Rx packet list. */
        list_for_each_entry_safe(pkt, pktback, &qc->rx.pkt_list, qc_rx_pkt_list) {
                LIST_DELETE(&pkt->qc_rx_pkt_list);