]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: add h3c pointer into h3s instance
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 3 Jun 2022 13:29:07 +0000 (15:29 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 7 Jun 2022 16:13:11 +0000 (18:13 +0200)
As a mirror to qcc/qcs types, add a h3c pointer into h3s struct. This
should help to clean up H3 code and avoid to use qcs.qcc.ctx to retrieve
the h3c instance.

include/haproxy/mux_quic-t.h
src/h3.c
src/hq_interop.c
src/mux_quic.c

index 51e3f882abcbbbd619e07ce5cf0f0a6e07f574a1..b32d4f9668b85b76197cf78524ab02f05987e6a3 100644 (file)
@@ -136,8 +136,8 @@ struct qcs {
 /* QUIC application layer operations */
 struct qcc_app_ops {
        int (*init)(struct qcc *qcc);
-       int (*attach)(struct qcs *qcs);
-       int (*decode_qcs)(struct qcs *qcs, int fin, void *ctx);
+       int (*attach)(struct qcs *qcs, void *conn_ctx);
+       int (*decode_qcs)(struct qcs *qcs, int fin);
        size_t (*snd_buf)(struct stconn *sc, struct buffer *buf, size_t count, int flags);
        void (*detach)(struct qcs *qcs);
        int (*finalize)(void *ctx);
index 1b8e3783103ae02c5d109028617e86d24b24b1e2..b9a9fed3615866200d261cd32ea0dc35b72d3332 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -133,6 +133,8 @@ DECLARE_STATIC_POOL(pool_head_h3c, "h3c", sizeof(struct h3c));
 #define H3_SF_UNI_NO_H3 0x00000002  /* unidirectional stream does not carry H3 frames */
 
 struct h3s {
+       struct h3c *h3c;
+
        enum h3s_t type;
        int demux_frame_len;
        int demux_frame_type;
@@ -574,11 +576,11 @@ static size_t h3_parse_settings_frm(struct h3c *h3c, const struct ncbuf *rxbuf,
  *
  * Returns 0 on success else non-zero.
  */
-static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
+static int h3_decode_qcs(struct qcs *qcs, int fin)
 {
        struct ncbuf *rxbuf = &qcs->rx.ncbuf;
-       struct h3c *h3c = ctx;
        struct h3s *h3s = qcs->ctx;
+       struct h3c *h3c = h3s->h3c;
        ssize_t ret;
 
        h3_debug_printf(stderr, "%s: STREAM ID: %lu\n", __func__, qcs->id);
@@ -1020,7 +1022,7 @@ size_t h3_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, int flags
        return total;
 }
 
-static int h3_attach(struct qcs *qcs)
+static int h3_attach(struct qcs *qcs, void *conn_ctx)
 {
        struct h3s *h3s;
 
@@ -1031,6 +1033,8 @@ static int h3_attach(struct qcs *qcs)
                return 1;
 
        qcs->ctx = h3s;
+       h3s->h3c = conn_ctx;
+
        h3s->demux_frame_len = 0;
        h3s->demux_frame_type = 0;
        h3s->flags = 0;
index c9ab683901e72e4a506501560a60ff9aad318eea..f5c0e79cdd45da4582b1840f1425393b0424a29f 100644 (file)
@@ -9,7 +9,7 @@
 #include <haproxy/mux_quic.h>
 #include <haproxy/ncbuf.h>
 
-static int hq_interop_decode_qcs(struct qcs *qcs, int fin, void *ctx)
+static int hq_interop_decode_qcs(struct qcs *qcs, int fin)
 {
        struct ncbuf *rxbuf = &qcs->rx.ncbuf;
        struct htx *htx;
index 04ed1bac679982d853c133dd631ada67dc75a2e3..84237c3e6e4e517d96df86d6f3ab7a7e61138da3 100644 (file)
@@ -139,7 +139,7 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
 
        qcs->id = qcs->by_id.key = id;
        if (qcc->app_ops->attach) {
-               if (qcc->app_ops->attach(qcs))
+               if (qcc->app_ops->attach(qcs, qcc->ctx))
                        goto err;
        }
 
@@ -434,7 +434,7 @@ static int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
 {
        TRACE_ENTER(QMUX_EV_QCS_RECV, qcc->conn, qcs);
 
-       if (qcc->app_ops->decode_qcs(qcs, qcs->flags & QC_SF_FIN_RECV, qcc->ctx)) {
+       if (qcc->app_ops->decode_qcs(qcs, qcs->flags & QC_SF_FIN_RECV)) {
                TRACE_DEVEL("leaving on decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs);
                return 1;
        }