]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: quic: move conn->qc into conn->handle
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Apr 2022 12:18:10 +0000 (14:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 Apr 2022 17:33:04 +0000 (19:33 +0200)
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.

include/haproxy/connection-t.h
src/connection.c
src/mux_quic.c
src/quic_sock.c
src/xprt_quic.c

index 9a03e9b81d212e3ff79e99f317287da3f6cd02aa..c86311a60abd6b28429c05f860e59efcbb958339 100644 (file)
@@ -327,10 +327,12 @@ struct wait_event {
 };
 
 /* 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 connection {
        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
index b666d18760a606fdc5af64187cce7c3eff6e4b87..a14dfe79219a5b1abd48063bbfa75d3b3af916d2 100644 (file)
@@ -433,7 +433,6 @@ void conn_init(struct connection *conn, void *target)
        conn->dst = NULL;
        conn->proxy_authority = IST_NULL;
        conn->proxy_unique_id = IST_NULL;
-       conn->qc = NULL;
        conn->hash_node = NULL;
        conn->xprt = NULL;
 }
index 786d8bdd41b7acd7697637ecb242836469d600a9..275b92a9df7fa057e22bb3ae97bf94396fe51a03 100644 (file)
@@ -159,7 +159,7 @@ void qcs_free(struct qcs *qcs)
 
        /* 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 @@ static void qc_release(struct qcc *qcc)
        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 @@ static int qc_send_frames(struct qcc *qcc, struct list *frms)
        }
 
        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 @@ static int qc_init(struct connection *conn, struct proxy *prx,
        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 @@ static int qc_init(struct connection *conn, struct proxy *prx,
        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 @@ static int qc_init(struct connection *conn, struct proxy *prx,
                }
        }
 
-       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_some_streams(struct qcc *qcc)
 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 @@ static int qc_wake(struct connection *conn)
        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);
index 022cd54694589fc82eb1fc4d0638eae237fe1385..1aa0015993aba6c68aeb753e1de95e3fe3ebe43a 100644 (file)
@@ -75,7 +75,7 @@ int quic_session_accept(struct connection *cli_conn)
        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 @@ int quic_sock_get_src(struct connection *conn, struct sockaddr *addr, socklen_t
 {
        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 @@ int quic_sock_get_dst(struct connection *conn, struct sockaddr *addr, socklen_t
 {
        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 @@ static int new_quic_cli_conn(struct quic_conn *qc, struct listener *l,
 
        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:
index 0565f79cefe15aca2735c27899d09194ff06b96a..abbedfd2ac62a12c78c2dfdb51a528e5e174442d 100644 (file)
@@ -5693,7 +5693,7 @@ static struct quic_tx_packet *qc_build_pkt(unsigned char **pos,
  */
 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 @@ static int quic_conn_subscribe(struct connection *conn, void *xprt_ctx, int even
        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 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
        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 @@ static int qc_xprt_start(struct connection *conn, void *ctx)
        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 int qc_xprt_start(struct connection *conn, void *ctx)
 
 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. */