]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: store ssl_sock_ctx reference into quic_conn
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 22 Dec 2021 17:20:38 +0000 (18:20 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Dec 2021 14:51:00 +0000 (15:51 +0100)
Add a pointer in quic_conn to its related ssl_sock_ctx. This change is
required to avoid to use the connection instance to access it.

This commit is part of the rearchitecture of xprt-quic layers and the
separation between xprt and connection instances. It will be notably
useful when the connection allocation will be delayed.

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

index fcb6adc8290867a8caec06a7110dc353fb37495d..8ae5eb27dcd2205e7711b2453c7fe67e05ce8869 100644 (file)
@@ -643,6 +643,7 @@ struct quic_conn {
        struct quic_enc_level els[QUIC_TLS_ENC_LEVEL_MAX];
        struct quic_pktns pktns[QUIC_TLS_PKTNS_MAX];
 
+       struct ssl_sock_ctx *xprt_ctx;
        /* Used only to reach the tasklet for the I/O handler from this quic_conn object. */
        struct connection *conn;
        /* Output buffer used during the handshakes. */
index 5874d1c354e5fbddd4160c66ad3b9bcebebb5ad5..5eac5c0b7b7e551f600ac710529374d82dbec1df 100644 (file)
@@ -4084,8 +4084,6 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
                }
                else {
                        pkt->qc = qc;
-                       if (HA_ATOMIC_LOAD(&qc->conn))
-                               conn_ctx = HA_ATOMIC_LOAD(&qc->conn->xprt_ctx);
                }
        }
        else {
@@ -4109,9 +4107,6 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
                        goto err;
                }
 
-               if (HA_ATOMIC_LOAD(&qc->conn))
-                       conn_ctx = HA_ATOMIC_LOAD(&qc->conn->xprt_ctx);
-
                pkt->qc = qc;
        }
 
@@ -4173,7 +4168,8 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
         * will start it if these contexts for the connection are not already
         * initialized.
         */
-       if (conn_ctx && HA_ATOMIC_LOAD(&conn_ctx->conn->ctx))
+       conn_ctx = HA_ATOMIC_LOAD(&qc->xprt_ctx);
+       if (conn_ctx && conn_ctx->wait_event.tasklet)
                tasklet_wakeup(conn_ctx->wait_event.tasklet);
 
        TRACE_LEAVE(QUIC_EV_CONN_LPKT, qc ? qc : NULL, pkt);
@@ -4997,6 +4993,7 @@ static int qc_ssl_sess_init(struct quic_conn *qc, SSL_CTX *ssl_ctx, SSL **ssl,
 static int qc_conn_init(struct connection *conn, void **xprt_ctx)
 {
        struct ssl_sock_ctx *ctx;
+       struct quic_conn *qc = NULL;
 
        TRACE_ENTER(QUIC_EV_CONN_NEW, conn);
 
@@ -5027,7 +5024,6 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
                /* Server */
                struct server *srv = __objt_server(conn->target);
                unsigned char dcid[QUIC_HAP_CID_LEN];
-               struct quic_conn *qc;
                int ssl_err, ipv4;
 
                ssl_err = SSL_ERROR_NONE;
@@ -5084,8 +5080,8 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
        else if (objt_listener(conn->target)) {
                /* Listener */
                struct bind_conf *bc = __objt_listener(conn->target)->bind_conf;
-               struct quic_conn *qc = ctx->conn->qc;
 
+               qc = ctx->conn->qc;
                ctx->qc = qc;
 
                qc->tid = ctx->wait_event.tasklet->tid = quic_get_cid_tid(&qc->scid);
@@ -5106,6 +5102,7 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
        conn->flags |= CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN;
 
  out:
+       HA_ATOMIC_STORE(&qc->xprt_ctx, ctx);
        TRACE_LEAVE(QUIC_EV_CONN_NEW, conn);
 
        return 0;