]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: add reference to quic_conn in ssl context
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 21 Dec 2021 10:41:52 +0000 (11:41 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 21 Dec 2021 14:53:19 +0000 (15:53 +0100)
Add a new member in ssl_sock_ctx structure to reference the quic_conn
instance if used in the QUIC stack. This member is initialized during
qc_conn_init().

This is needed to be able to access to the quic_conn without relying on
the connection instance. This commit is part of the rearchitecture of
xprt-quic layers and the separation between xprt and connection
instances.

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

index 6a239715e385c2b1a3f4f0f637ce2ffd8db6d3ad..fab8decbff5ca2c01038f284d1f9df37737798bb 100644 (file)
@@ -245,6 +245,9 @@ struct ssl_sock_ctx {
        struct buffer early_buf;      /* buffer to store the early data received */
        int sent_early_data;          /* Amount of early data we sent so far */
 
+#ifdef USE_QUIC
+       struct quic_conn *qc;
+#endif
 };
 
 struct global_ssl {
index 86936bc167ff67692afca4caf6be17c07b69a771..ae5241f6e202eae0ae6e2174fc0934fa0e82e4a1 100644 (file)
@@ -652,7 +652,7 @@ static inline void qc_set_timer(struct ssl_sock_ctx *ctx)
 
        TRACE_ENTER(QUIC_EV_CONN_STIMER, ctx->conn,
                    NULL, NULL, &ctx->conn->qc->path->ifae_pkts);
-       qc = ctx->conn->qc;
+       qc = ctx->qc;
        pktns = quic_loss_pktns(qc);
        if (tick_isset(pktns->tx.loss_time)) {
                qc->timer = pktns->tx.loss_time;
@@ -1451,7 +1451,7 @@ static inline void qc_treat_acked_tx_frm(struct quic_frame *frm,
                                          struct ssl_sock_ctx *ctx)
 {
        int stream_acked;
-       struct quic_conn *qc = ctx->conn->qc;
+       struct quic_conn *qc = ctx->qc;
 
        TRACE_PROTO("Removing frame", QUIC_EV_CONN_PRSAFRM, ctx->conn, frm);
        stream_acked = 0;
@@ -1866,7 +1866,8 @@ static inline int qc_provide_cdata(struct quic_enc_level *el,
 
        TRACE_ENTER(QUIC_EV_CONN_SSLDATA, ctx->conn);
        ssl_err = SSL_ERROR_NONE;
-       qc = ctx->conn->qc;
+       qc = ctx->qc;
+
        if (SSL_provide_quic_data(ctx->ssl, el->level, data, len) != 1) {
                TRACE_PROTO("SSL_provide_quic_data() error",
                            QUIC_EV_CONN_SSLDATA, ctx->conn, pkt, cf, ctx->ssl);
@@ -2200,7 +2201,7 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
 {
        struct quic_frame frm;
        const unsigned char *pos, *end;
-       struct quic_conn *qc = ctx->conn->qc;
+       struct quic_conn *qc = ctx->qc;
 
        TRACE_ENTER(QUIC_EV_CONN_PRSHPKT, ctx->conn);
        /* Skip the AAD */
@@ -2405,7 +2406,8 @@ static int qc_prep_pkts(struct qring *qr, struct ssl_sock_ctx *ctx)
        size_t dg_headlen = sizeof dglen + sizeof first_pkt;
 
        TRACE_ENTER(QUIC_EV_CONN_PHPKTS, ctx->conn);
-       qc = ctx->conn->qc;
+       qc = ctx->qc;
+
        if (!quic_get_tls_enc_levels(&tel, &next_tel, HA_ATOMIC_LOAD(&qc->state), 0)) {
                TRACE_DEVEL("unknown enc. levels", QUIC_EV_CONN_PHPKTS, ctx->conn);
                goto err;
@@ -2596,7 +2598,7 @@ int qc_send_ppkts(struct qring *qr, struct ssl_sock_ctx *ctx)
        struct quic_conn *qc;
        struct cbuf *cbuf;
 
-       qc = ctx->conn->qc;
+       qc = ctx->qc;
        cbuf = qr->cbuf;
        while (cb_contig_data(cbuf)) {
                unsigned char *pos;
@@ -3076,7 +3078,7 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
        int prev_st, st, force_ack, zero_rtt;
 
        ctx = context;
-       qc = ctx->conn->qc;
+       qc = ctx->qc;
        qr = NULL;
        st = HA_ATOMIC_LOAD(&qc->state);
        TRACE_ENTER(QUIC_EV_CONN_HDSHK, ctx->conn, &st);
@@ -3264,7 +3266,7 @@ static struct task *process_timer(struct task *task, void *ctx, unsigned int sta
        int st;
 
        conn_ctx = task->context;
-       qc = conn_ctx->conn->qc;
+       qc = conn_ctx->qc;
        TRACE_ENTER(QUIC_EV_CONN_PTIMER, conn_ctx->conn,
                    NULL, NULL, &qc->path->ifae_pkts);
        task->expire = TICK_ETERNITY;
@@ -5051,6 +5053,8 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
                if (qc == NULL)
                        goto err;
 
+               ctx->qc = qc;
+
                /* Insert our SCID, the connection ID for the QUIC client. */
                ebmb_insert(&srv->cids, &qc->scid_node, qc->scid.len);
 
@@ -5095,6 +5099,8 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
                struct bind_conf *bc = __objt_listener(conn->target)->bind_conf;
                struct quic_conn *qc = ctx->conn->qc;
 
+               ctx->qc = qc;
+
                qc->tid = ctx->wait_event.tasklet->tid = quic_get_cid_tid(&qc->scid);
                if (qc_ssl_sess_init(qc, bc->initial_ctx, &ctx->ssl,
                                     qc->enc_params, qc->enc_params_len) == -1)