MINOR: quic: store ssl_sock_ctx reference into quic_conn
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.
diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h
index fcb6adc..8ae5eb2 100644
--- a/include/haproxy/xprt_quic-t.h
+++ b/include/haproxy/xprt_quic-t.h
@@ -643,6 +643,7 @@
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. */
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index 5874d1c..5eac5c0 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -4084,8 +4084,6 @@
}
else {
pkt->qc = qc;
- if (HA_ATOMIC_LOAD(&qc->conn))
- conn_ctx = HA_ATOMIC_LOAD(&qc->conn->xprt_ctx);
}
}
else {
@@ -4109,9 +4107,6 @@
goto err;
}
- if (HA_ATOMIC_LOAD(&qc->conn))
- conn_ctx = HA_ATOMIC_LOAD(&qc->conn->xprt_ctx);
-
pkt->qc = qc;
}
@@ -4173,7 +4168,8 @@
* 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_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 @@
/* 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 @@
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 @@
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;