MEDIUM: quic: move conn->qc into conn->handle
It was supposed to be there, and probably was not placed there due to
historic limitations in listener_accept(), but now there does not seem
to be a remaining valid reason for keeping the quic_conn out of the
handle. In addition in new_quic_cli_conn() the handle->fd was incorrectly
set to the listener's FD.
diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h
index 9a03e9b..c86311a 100644
--- a/include/haproxy/connection-t.h
+++ b/include/haproxy/connection-t.h
@@ -327,10 +327,12 @@
};
/* A connection handle is how we differentiate two connections on the lower
- * layers. It usually is a file descriptor but can be a connection id.
+ * layers. It usually is a file descriptor but can be a connection id. The
+ * CO_FL_FDLESS flag indicates which one is relevant.
*/
union conn_handle {
- int fd; /* file descriptor, for regular sockets */
+ struct quic_conn *qc; /* Only present if this connection is a QUIC one (CO_FL_FDLESS=1) */
+ int fd; /* file descriptor, for regular sockets (CO_FL_FDLESS=0) */
};
/* xprt_ops describes transport-layer operations for a connection. They
@@ -497,7 +499,6 @@
struct sockaddr_storage *dst; /* destination address (pool), when known, otherwise NULL */
struct ist proxy_authority; /* Value of the authority TLV received via PROXYv2 */
struct ist proxy_unique_id; /* Value of the unique ID TLV received via PROXYv2 */
- struct quic_conn *qc; /* Only present if this connection is a QUIC one */
/* used to identify a backend connection for http-reuse,
* thus only present if conn.target is of type OBJ_TYPE_SERVER
diff --git a/src/connection.c b/src/connection.c
index b666d18..a14dfe7 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -433,7 +433,6 @@
conn->dst = NULL;
conn->proxy_authority = IST_NULL;
conn->proxy_unique_id = IST_NULL;
- conn->qc = NULL;
conn->hash_node = NULL;
conn->xprt = NULL;
}
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 786d8bd..275b92a 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -159,7 +159,7 @@
/* stream desc must be removed from MUX tree before release it */
eb64_delete(&qcs->stream->by_id);
- qc_stream_desc_release(qcs->stream, qcs->qcc->conn->qc);
+ qc_stream_desc_release(qcs->stream, qcs->qcc->conn->handle.qc);
pool_free(pool_head_qcs, qcs);
}
@@ -521,7 +521,7 @@
if (conn) {
LIST_DEL_INIT(&conn->stopping_list);
- conn->qc->conn = NULL;
+ conn->handle.qc->conn = NULL;
conn->mux = NULL;
conn->ctx = NULL;
@@ -715,7 +715,7 @@
}
if (!LIST_ISEMPTY(frms))
- qc_send_app_pkts(qcc->conn->qc, frms);
+ qc_send_app_pkts(qcc->conn->handle.qc, frms);
/* If there is frames left, check if the transport layer has send some
* data or is blocked.
@@ -976,7 +976,7 @@
qcc->streams_by_id = EB_ROOT_UNIQUE;
/* Server parameters, params used for RX flow control. */
- lparams = &conn->qc->rx.params;
+ lparams = &conn->handle.qc->rx.params;
qcc->rx.max_data = lparams->initial_max_data;
qcc->tx.sent_offsets = 0;
@@ -1010,7 +1010,7 @@
qcc->lfctl.ms_bidi = qcc->lfctl.ms_bidi_init = lparams->initial_max_streams_bidi;
qcc->lfctl.cl_bidi_r = 0;
- rparams = &conn->qc->tx.params;
+ rparams = &conn->handle.qc->tx.params;
qcc->rfctl.md = rparams->initial_max_data;
qcc->rfctl.msd_bidi_l = rparams->initial_max_stream_data_bidi_local;
qcc->rfctl.msd_bidi_r = rparams->initial_max_stream_data_bidi_remote;
@@ -1040,7 +1040,7 @@
}
}
- HA_ATOMIC_STORE(&conn->qc->qcc, qcc);
+ HA_ATOMIC_STORE(&conn->handle.qc->qcc, qcc);
/* init read cycle */
tasklet_wakeup(qcc->wait_event.tasklet);
@@ -1240,7 +1240,7 @@
static int qc_wake(struct connection *conn)
{
struct qcc *qcc = conn->ctx;
- struct proxy *prx = conn->qc->li->bind_conf->frontend;
+ struct proxy *prx = conn->handle.qc->li->bind_conf->frontend;
TRACE_ENTER(QMUX_EV_QCC_WAKE, conn);
@@ -1252,7 +1252,7 @@
if (unlikely(prx->flags & (PR_FL_DISABLED|PR_FL_STOPPED)))
goto release;
- if (conn->qc->flags & QUIC_FL_CONN_NOTIFY_CLOSE)
+ if (conn->handle.qc->flags & QUIC_FL_CONN_NOTIFY_CLOSE)
qcc->conn->flags |= (CO_FL_SOCK_RD_SH|CO_FL_SOCK_WR_SH);
qc_send(qcc);
diff --git a/src/quic_sock.c b/src/quic_sock.c
index 022cd54..1aa0015 100644
--- a/src/quic_sock.c
+++ b/src/quic_sock.c
@@ -75,7 +75,7 @@
sess->listener = NULL;
session_free(sess);
out_free_conn:
- cli_conn->qc->conn = NULL;
+ cli_conn->handle.qc->conn = NULL;
conn_stop_tracking(cli_conn);
conn_xprt_close(cli_conn);
conn_free(cli_conn);
@@ -89,10 +89,10 @@
{
struct quic_conn *qc;
- if (!conn || !conn->qc)
+ if (!conn || !conn->handle.qc)
return -1;
- qc = conn->qc;
+ qc = conn->handle.qc;
if (conn_is_back(conn)) {
/* no source address defined for outgoing connections for now */
return -1;
@@ -110,10 +110,10 @@
{
struct quic_conn *qc;
- if (!conn || !conn->qc)
+ if (!conn || !conn->handle.qc)
return -1;
- qc = conn->qc;
+ qc = conn->handle.qc;
if (conn_is_back(conn)) {
/* back connection, return the peer's address */
if (len > sizeof(qc->peer_addr))
@@ -151,9 +151,8 @@
cli_conn->flags |= CO_FL_ADDR_FROM_SET | CO_FL_FDLESS;
qc->conn = cli_conn;
- cli_conn->qc = qc;
+ cli_conn->handle.qc = qc;
- cli_conn->handle.fd = l->rx.fd;
cli_conn->target = &l->obj_type;
/* We need the xprt context before accepting (->accept()) the connection:
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index 0565f79..abbedfd 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -5693,7 +5693,7 @@
*/
static int quic_conn_subscribe(struct connection *conn, void *xprt_ctx, int event_type, struct wait_event *es)
{
- struct qcc *qcc = conn->qc->qcc;
+ struct qcc *qcc = conn->handle.qc->qcc;
BUG_ON(event_type & ~(SUB_RETRY_SEND|SUB_RETRY_RECV));
BUG_ON(qcc->subs && qcc->subs != es);
@@ -5702,10 +5702,10 @@
qcc->subs = es;
if (event_type & SUB_RETRY_RECV)
- TRACE_DEVEL("subscribe(recv)", QUIC_EV_CONN_XPRTRECV, conn->qc, qcc);
+ TRACE_DEVEL("subscribe(recv)", QUIC_EV_CONN_XPRTRECV, conn->handle.qc, qcc);
if (event_type & SUB_RETRY_SEND)
- TRACE_DEVEL("subscribe(send)", QUIC_EV_CONN_XPRTSEND, conn->qc, qcc);
+ TRACE_DEVEL("subscribe(send)", QUIC_EV_CONN_XPRTSEND, conn->handle.qc, qcc);
return 0;
}
@@ -5732,7 +5732,7 @@
if (*xprt_ctx)
goto out;
- *xprt_ctx = conn->qc->xprt_ctx;
+ *xprt_ctx = conn->handle.qc->xprt_ctx;
out:
TRACE_LEAVE(QUIC_EV_CONN_NEW, qc);
@@ -5746,7 +5746,7 @@
struct quic_conn *qc;
struct ssl_sock_ctx *qctx = ctx;
- qc = conn->qc;
+ qc = conn->handle.qc;
if (qcc_install_app_ops(qc->qcc, qc->app_ops)) {
TRACE_PROTO("Cannot install app layer", QUIC_EV_CONN_LPKT, qc);
return 0;
@@ -5761,10 +5761,10 @@
static struct ssl_sock_ctx *qc_get_ssl_sock_ctx(struct connection *conn)
{
- if (!conn || conn->xprt != xprt_get(XPRT_QUIC) || !conn->qc || !conn->xprt_ctx)
+ if (!conn || conn->xprt != xprt_get(XPRT_QUIC) || !conn->handle.qc || !conn->xprt_ctx)
return NULL;
- return conn->qc->xprt_ctx;
+ return conn->handle.qc->xprt_ctx;
}
/* transport-layer operations for QUIC connections. */