MINOR: quic: add reference to quic_conn in ssl context
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.
diff --git a/include/haproxy/ssl_sock-t.h b/include/haproxy/ssl_sock-t.h
index 6a23971..fab8dec 100644
--- a/include/haproxy/ssl_sock-t.h
+++ b/include/haproxy/ssl_sock-t.h
@@ -245,6 +245,9 @@
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 {
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index 86936bc..ae5241f 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -652,7 +652,7 @@
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)